emscripten-tutorial

How to build an increasingly complex C/C++ codebase to WebAssembly
git clone https://git.tronto.net/emscripten-tutorial
Download | Log | Files | Refs | README

program.mjs (328B)


      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);