Skip to content

Instantly share code, notes, and snippets.

Created November 26, 2017 17:07
Show Gist options
  • Save anonymous/3990dc2d1ab4ae9776cd09f4b0523031 to your computer and use it in GitHub Desktop.
Save anonymous/3990dc2d1ab4ae9776cd09f4b0523031 to your computer and use it in GitHub Desktop.
fn main() {}
#[no_mangle]
pub fn add_one(x: i32) -> i32 {
x + 1
}
const fs = require('fs');
const buf = fs.readFileSync('./hello.wasm');
var m = new WebAssembly.Instance(new WebAssembly.Module(buf));
var h = new Uint8Array(m.exports.memory.buffer);
var p = m.exports.add_one(3);
console.log(p)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment