Skip to content

Instantly share code, notes, and snippets.

@vbkmr
Created January 13, 2020 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vbkmr/3a5975f37a78daab06716457940a1237 to your computer and use it in GitHub Desktop.
Save vbkmr/3a5975f37a78daab06716457940a1237 to your computer and use it in GitHub Desktop.
fetch('factorial.wasm')
//getting WASM Module from response
.then(response => response.arrayBuffer())
//instantiating WASM instance from WASM Module
.then(bytes => WebAssembly.instantiate(bytes))
//using exported factorial fn from WASM Instance
.then(results => {
console.log(results.instance.exports.factorial(12))
})
WebAssembly.instantiateStreaming(fetch("factorial.wasm")).then(results => {
console.log(results.instance.exports.factorial(12));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment