webassembly wat text format to binary compiler
🔧 Install · 🧩 Example · 📜 API docs · 🔥 Releases · 💪🏼 Contribute · 🖐️ Help
$ npm i wat-compilerCompiles a WAT source string to a buffer.
import compile from 'wat-compiler'
const buffer = compile('(func (export "answer") (result i32) (i32.const 42))')
const mod = new WebAssembly.Module(buffer)
const instance = new WebAssembly.Instance(mod)
console.log(instance.exports.answer()) // => 42-
codestring The WAT code to compile -
optionsOptions An options objectoptions.metricsboolean Enable metrics with console.time
-
context(optional, default{})
Returns Uint8Array The buffer to be passed on to WebAssembly
All contributions are welcome!
Public Domain © 2021 stagas