1"use strict"; 2const fs = require("fs"); 3const path = require("path"); 4const assert = require("assert"); 5 6const main = async function (typ, dir) { 7 const wasm_file = path.join( 8 __dirname, 9 dir, 10 "hello_world_" + typ + "_wasm_bindgen_bg.wasm", 11 ); 12 const buf = fs.readFileSync(wasm_file); 13 assert.ok(buf); 14 15 const res = await WebAssembly.instantiate(buf); 16 assert.ok(res); 17 assert.strictEqual(res.instance.exports.double(2), 4); 18}; 19 20["bundler", "web", "deno", "nomodules", "nodejs"].forEach((typ) => { 21 main(typ, process.argv.length > 2 ? process.argv[2] : "").catch(function ( 22 err, 23 ) { 24 console.error(err); 25 process.exit(1); 26 }); 27}); 28