-
-
Save bryanburgers/ec1be23f116591264ef710a77f49c1fc to your computer and use it in GitHub Desktop.
Runner for wasm articles
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("node:fs"); | |
const filename = process.argv[2]; | |
const wasmBuffer = fs.readFileSync(filename); | |
WebAssembly.instantiate(wasmBuffer).then((wasmModule) => { | |
const { main } = wasmModule.instance.exports; | |
const output = main(); | |
console.log(output); | |
}); |
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
# wasm-tools comes from https://github.com/bytecodealliance/wasm-tools | |
# wat2wasm from https://github.com/WebAssembly/wabt would also work | |
%.wasm: %.wat | |
wasm-tools parse $^ -o $@ | |
%: %.wasm | |
node index.js $^ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment