public/js/workers/primes.js
// A module worker (§38): same function, different thread.
import { countPrimes } from "../lib/primes.js";
self.onmessage = ({ data: { limit } }) => {
const t0 = performance.now();
const count = countPrimes(limit);
self.postMessage({ count, ms: performance.now() - t0 });
};