aboutsummaryrefslogtreecommitdiff
path: root/05_callback/worker.mjs
diff options
context:
space:
mode:
Diffstat (limited to '05_callback/worker.mjs')
-rw-r--r--05_callback/worker.mjs12
1 files changed, 12 insertions, 0 deletions
diff --git a/05_callback/worker.mjs b/05_callback/worker.mjs
new file mode 100644
index 0000000..736e9f8
--- /dev/null
+++ b/05_callback/worker.mjs
@@ -0,0 +1,12 @@
1import Primes from "./build/primes.mjs";
2
3var primes = await Primes();
4const logPtr = primes.addFunction((cstr) => {
5 postMessage({ message: primes.UTF8ToString(cstr) });
6}, "vp");
7
8onmessage = (e) => {
9 const count = primes._primes_in_range(e.data.a, e.data.b, logPtr);
10 postMessage({ message: "There are " + count + " primes between " +
11 e.data.a + " and " + e.data.b });
12};

Generated with cgit - Back to sebastiano.tronto.net