UNPKG

wasmexplorer-wasm-compiler

Version:

Compile `.c/++` files to `.wasm` format using [WasmExplorer](https://mbebenita.github.io/WasmExplorer/) service by [@mbebenita](https://github.com/mbebenita).

21 lines (18 loc) 405 B
<script> function loadWasm(url, imports = {}) { return fetch(url) .then(res => { if (res.ok) { return res.arrayBuffer(); } console.error(res); throw Error(); }) .then(binary => WebAssembly.instantiate(binary, imports)) .then(({ module, instance }) => instance.exports); } loadWasm('test.wasm').then(m => { console.log(m); console.log(m.fact(4)); }); </script>