开发者社区> 镜像站> NPM> wasm2js
wasm2js
Compile WebAssembly .wasm files to a commonjs module.
Last updated 2 years ago by thlorenz .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install wasm2js 
SYNC missed versions from official npm registry.

wasm2js

Compile WebAssembly .wasm files to a commonjs module.

const wasm2js = require('wasm2js')
const fs = require('fs')

const wasmBuffer = fs.readFileSync('path/to/my.wasm')
const js = wasm2js(wasmBuffer)

CLI

wasm2js example.wasm -o example.js

Installation

npm install wasm2js

API

wasm2js

Takes a .wasm binary and wraps it inside a commonJS module that can be required in Node.js and the browser.

Parameters

  • wasmBuf Buffer a buffer of the .wasm code

Returns String the commonJS module code that wraps the wasm

Kudos

90% of this code was extracted from @mafintosh's wat2js.

License

MIT

Current Tags

  • 0.2.0                                ...           latest (2 years ago)

4 Versions

  • 0.2.0                                ...           2 years ago
  • 0.1.2                                ...           2 years ago
  • 0.1.1                                ...           3 years ago
  • 0.1.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 1
Last Month 7
Dependencies (1)
Dev Dependencies (0)
None
Dependents (1)