Skip to content

Instantly share code, notes, and snippets.

@andrei-cacio
Last active June 3, 2018 13:05
Show Gist options
  • Save andrei-cacio/43fde9efcd747ac8c79764cb206606d5 to your computer and use it in GitHub Desktop.
Save andrei-cacio/43fde9efcd747ac8c79764cb206606d5 to your computer and use it in GitHub Desktop.
fetch('memory-access.gc.wasm')
.then(r => r.arrayBuffer())
.then(arrayBuff => WebAssembly.instantiate(arrBuff, {}))
.then(rustWasm => {
const vecLocation = wasmRust.instance.exports.simple_arr();
const vecTyped = new Uint32Array(wasmRust.instance.exports.memory.buffer, vecLocation, 4);
const simpleVec = [...vecTyped]
console.log(simpleVec)
// [ 100, 200, 300, 400 ]
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment