Created
August 26, 2017 16:41
-
-
Save gskachkov/4599c39b997d5dfcc2792342746756df to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const importObject = { | |
imports: { | |
foo: arg => { | |
console.log('Imported value from WASM', arg); | |
} | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fetch('simple.wasm') | |
.then(response => response.arrayBuffer()) | |
.then(bytes => WebAssembly.instantiate(bytes, importObject)) | |
.then(results => { | |
results.instance.exports.exported_func(); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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