-
-
Save mizchi/b2c4999bd895accf3078122ae9f47051 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() {} | |
#[no_mangle] | |
pub fn add_one(x: i32) -> i32 { | |
x + 1 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
$ rustc +nightly --target wasm32-unknown-unknown -O hello.rs
$ node --expose-wasm run.js
4