blob: 929fabc0ab107f88cace3a28e93fa869c2f4fd00 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
import Primes from "./build/primes.mjs";
var primes = await Primes();
const logPtr = primes.addFunction((cstr) => {
const str = primes.UTF8ToString(cstr);
console.log(str);
postMessage({ message: str });
}, "vp");
onmessage = (e) => {
const count = primes._primes_in_range(e.data.a, e.data.b, logPtr);
postMessage({
type: "response",
message: "There are " + count + " primes between " +
e.data.a + " and " + e.data.b
});
};
primes.fileSystemLoaded.then(() => {
postMessage({ type: "readySignal" });
});
|