Skip to content

Instantly share code, notes, and snippets.

@gonzaloruizdevilla
Created September 5, 2019 15:01
Show Gist options
  • Save gonzaloruizdevilla/a8743476a732974bcfbdf63c39d88ff7 to your computer and use it in GitHub Desktop.
Save gonzaloruizdevilla/a8743476a732974bcfbdf63c39d88ff7 to your computer and use it in GitHub Desktop.
//A memory created by JavaScript or in WebAssembly code will be accessible and mutable from both JavaScript and WebAssembly.
const memory = new WebAssembly.Memory({ initial:initial * 2 });
//Instantiating Wasm module
const importObject = { env: { memory, abort: () => console.log("Abort!") }};
const {instance} = await WebAssembly.instantiateStreaming(
fetch("./build/untouched.wasm"),
importObject
);
//Creating a typed array reference to write into the memory buffer
const mem = new Uint8Array(memory.buffer);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment