From 73efecca42dbc44200e797e02f8c1e24fcff26ef Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Thu, 5 Jun 2025 10:13:28 +0200 Subject: Added two more examples --- 05_callback/program.mjs | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 05_callback/program.mjs (limited to '05_callback/program.mjs') diff --git a/05_callback/program.mjs b/05_callback/program.mjs new file mode 100644 index 0000000..fd85a58 --- /dev/null +++ b/05_callback/program.mjs @@ -0,0 +1,11 @@ +import Primes from "./build/primes.mjs" + +var primes = await Primes(); +const logPtr = primes.addFunction((cstr) => { + console.log(primes.UTF8ToString(cstr)); +}, 'vp'); + +const a = 1; +const b = 10000000; +const count = primes._primes_in_range(a, b, logPtr); +console.log("There are " + count + " primes between " + a + " and " + b); -- cgit v1.3