mirror of
https://github.com/denoland/deno.git
synced 2024-12-28 10:09:20 -05:00
20 lines
486 B
JavaScript
20 lines
486 B
JavaScript
|
const scope = import.meta.url.slice(-7) === "#worker" ? "worker" : "main";
|
||
|
|
||
|
new Worker(`data:application/javascript;base64,${btoa(`postMessage("ok");`)}`, {
|
||
|
type: "module",
|
||
|
deno: {
|
||
|
permissions: {
|
||
|
read: true,
|
||
|
},
|
||
|
},
|
||
|
}).onmessage = ({ data }) => {
|
||
|
console.log(scope, data);
|
||
|
|
||
|
if (scope === "main") {
|
||
|
const worker = new Worker(`${import.meta.url}#worker`, { type: "module" });
|
||
|
worker.onmessage = () => Deno.exit(0);
|
||
|
} else {
|
||
|
postMessage("done");
|
||
|
}
|
||
|
};
|