aboutsummaryrefslogtreecommitdiff
path: root/05_callback/worker.mjs
blob: 736e9f8b2cf77b3f99b3153a1428f9981d9ee748 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
import Primes from "./build/primes.mjs";

var primes = await Primes();
const logPtr = primes.addFunction((cstr) => {
	postMessage({ message: primes.UTF8ToString(cstr) });
}, "vp");

onmessage = (e) => {
	const count = primes._primes_in_range(e.data.a, e.data.b, logPtr);
	postMessage({ message: "There are " + count + " primes between " +
		e.data.a + " and " + e.data.b });
};

Generated with cgit - Back to sebastiano.tronto.net