Skip to content

Instantly share code, notes, and snippets.

@gskachkov
Created August 26, 2017 16:41
Show Gist options
  • Save gskachkov/4599c39b997d5dfcc2792342746756df to your computer and use it in GitHub Desktop.
Save gskachkov/4599c39b997d5dfcc2792342746756df to your computer and use it in GitHub Desktop.
const importObject = {
imports: {
foo: arg => {
console.log('Imported value from WASM', arg);
}
}
};
fetch('simple.wasm')
.then(response => response.arrayBuffer())
.then(bytes => WebAssembly.instantiate(bytes, importObject))
.then(results => {
results.instance.exports.exported_func();
});
(module
(func $i (import "imports" "foo") (param i32))
(func (export "exported_func")
i32.const 30
call $i))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment