iris/_examples/webassembly/basic/client/main.js
Gerasimos (Makis) Maropoulos cd5109ae0e Iris + WebAssemply = = 💓
Former-commit-id: 44f08f112cfba8006d2a6fe34e32b24e5c246856
2018-07-09 09:13:36 +03:00

13 lines
496 B
JavaScript

import './go-wasm-runtime.js';
if (!WebAssembly.instantiateStreaming) { // polyfill
WebAssembly.instantiateStreaming = async (resp, importObject) => {
const source = await (await resp).arrayBuffer();
return await WebAssembly.instantiate(source, importObject);
};
}
const go = new Go();
WebAssembly.instantiateStreaming(fetch("hello.wasm"), go.importObject).then((result) => {
return WebAssembly.instantiate(result.module, go.importObject);
}).then(instance => go.run(instance));