1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-29 02:29:06 -05:00
denoland-deno/tests/specs/node/worker_threads_cache/main.ts

14 lines
403 B
TypeScript
Raw Normal View History

import fs from "node:fs/promises";
import { isMainThread, Worker } from "node:worker_threads";
await fs.writeFile("mod.mjs", "export default " + isMainThread);
const path = new URL("mod.mjs", import.meta.url);
const i = await import(path.href);
console.log(i);
if (isMainThread) {
const worker = new Worker(new URL("main.ts", import.meta.url));
worker.on("message", (msg) => console.log(msg));
}