diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-06-05 10:13:28 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-06-05 10:13:28 +0200 |
| commit | 73efecca42dbc44200e797e02f8c1e24fcff26ef (patch) | |
| tree | 46969fed9d5c09a4164257dace56a71cad9092ab /05_callback/program.mjs | |
| parent | 2a8e7aeeef99161b6f0378ac14e297c23ca6227b (diff) | |
| download | emscripten-tutorial-73efecca42dbc44200e797e02f8c1e24fcff26ef.tar.gz emscripten-tutorial-73efecca42dbc44200e797e02f8c1e24fcff26ef.zip | |
Added two more examples
Diffstat (limited to '')
| -rw-r--r-- | 05_callback/program.mjs | 11 |
1 files changed, 11 insertions, 0 deletions
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 @@ | |||
| 1 | import Primes from "./build/primes.mjs" | ||
| 2 | |||
| 3 | var primes = await Primes(); | ||
| 4 | const logPtr = primes.addFunction((cstr) => { | ||
| 5 | console.log(primes.UTF8ToString(cstr)); | ||
| 6 | }, 'vp'); | ||
| 7 | |||
| 8 | const a = 1; | ||
| 9 | const b = 10000000; | ||
| 10 | const count = primes._primes_in_range(a, b, logPtr); | ||
| 11 | console.log("There are " + count + " primes between " + a + " and " + b); | ||
