Published unlisted
Edited
Jul 13, 2022
16 stars
Insert cell
Insert cell
Insert cell
instance = {
let instance;
const imports = {
env: {
consoleLog: (location, size) => consoleLog(instance, location, size)
}
};
return FileAttachment("main.wasm")
.arrayBuffer()
.then((bytes) => WebAssembly.instantiate(bytes, imports))
.then((results) => (instance = results.instance));
}
Insert cell
Insert cell
add = instance.exports.add
Insert cell
add(1200, 34)
Insert cell
consoleLog = (instance, location, size) => {
const buffer = new Uint8Array(instance.exports.memory.buffer, location, size);
const decoder = new TextDecoder();
const string = decoder.decode(buffer);
console.log(string);
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more