mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
Co-authored-by: 190n <7763597+190n@users.noreply.github.com> Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
15 lines
287 B
JavaScript
15 lines
287 B
JavaScript
import { isMainThread } from "bun";
|
|
|
|
console.log("isMainThread", isMainThread);
|
|
|
|
if (isMainThread) {
|
|
const worker = new Worker(import.meta.url);
|
|
const { promise, resolve } = Promise.withResolvers();
|
|
|
|
worker.addEventListener("open", () => {
|
|
resolve();
|
|
});
|
|
|
|
await promise;
|
|
}
|