wat-compiler
v1.1.1
Published
webassembly wat text format to binary compiler
Downloads
36
Readme
Install
$ npm i wat-compiler
API
Table of Contents
make
Compiles 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
Parameters
code
string The WAT code to compileoptions
Options An options objectoptions.metrics
boolean Enable metrics with console.time
context
(optional, default{}
)
Returns Uint8Array The buffer to be passed on to WebAssembly
Contribute
All contributions are welcome!
License
Public Domain © 2021 stagas