mirror of
https://github.com/denoland/deno.git
synced 2024-12-15 03:48:02 -05:00
14 lines
325 B
TypeScript
14 lines
325 B
TypeScript
|
export function addAsync(a: number, b: number): Promise<number> {
|
||
|
const worker = new Worker(import.meta.resolve("./worker.ts"), {
|
||
|
type: "module",
|
||
|
});
|
||
|
|
||
|
return new Promise((resolve) => {
|
||
|
worker.addEventListener("message", (event) => {
|
||
|
resolve(event.data);
|
||
|
});
|
||
|
|
||
|
worker.postMessage({ a, b });
|
||
|
});
|
||
|
}
|