Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stagas/wat-compiler
webassembly wat text format to binary compiler
https://github.com/stagas/wat-compiler
binary bytecode compiler wabt wasm wat webassembly
Last synced: 6 days ago
JSON representation
webassembly wat text format to binary compiler
- Host: GitHub
- URL: https://github.com/stagas/wat-compiler
- Owner: stagas
- Created: 2021-01-29T19:10:44.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-12-07T17:33:45.000Z (almost 2 years ago)
- Last Synced: 2024-10-11T00:35:26.412Z (27 days ago)
- Topics: binary, bytecode, compiler, wabt, wasm, wat, webassembly
- Language: JavaScript
- Homepage:
- Size: 460 KB
- Stars: 20
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
wat-compiler
webassembly wat text format to binary compiler
🔧 Install
· 🧩 Example
· 📜 API docs
· 🔥 Releases
· 💪🏼 Contribute
· 🖐️ Help***
## Install
```sh
$ npm i wat-compiler
```## API
#### Table of Contents
* [make](#make)
* [Parameters](#parameters)### make
[index.js:25-27](https://github.com/stagas/wat-compiler/blob/da299d9672ca3cf692083212afadad27720fd8f1/index.js#L25-L27 "Source code on GitHub")
Compiles a WAT source string to a buffer.
```js
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](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The WAT code to compile
* `options` **Options** An options object* `options.metrics` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Enable metrics with console.time
* `context` (optional, default `{}`)Returns **[Uint8Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array)** The buffer to be passed on to WebAssembly
## Contribute
[Fork](https://github.com/stagas/wat-compiler/fork) or
[edit](https://github.dev/stagas/wat-compiler) and submit a PR.All contributions are welcome!
## License
Public Domain © 2021
[stagas](https://github.com/stagas)