Home

Awesome

wabt.js

wabt.js is a port of WABT to the Web, allowing you to manipulate WebAssembly modules using a JavaScript API.

<a href="https://github.com/AssemblyScript/wabt.js/actions?query=workflow%3ABuild"><img src="https://img.shields.io/github/actions/workflow/status/AssemblyScript/wabt.js/build.yml?branch=main&label=build&logo=github" alt="Build status" /></a> <a href="https://www.npmjs.com/package/wabt"><img src="https://img.shields.io/npm/v/wabt.svg?label=latest&color=007acc&logo=npm" alt="npm version" /></a> <a href="https://www.npmjs.com/package/wabt"><img src="https://img.shields.io/npm/v/wabt/nightly.svg?label=nightly&color=007acc&logo=npm" alt="npm nightly version" /></a>

Usage

$> npm install wabt
require("wabt")().then(wabt => {
  var wasm = ...; // a buffer holding the contents of a wasm file

  var myModule = wabt.readWasm(wasm, { readDebugNames: true });
  myModule.applyNames();

  var wast = myModule.toText({ foldExprs: false, inlineExport: false });

  console.log(wast);
});

The buildbot also publishes nightly versions once a day if there have been changes. The latest nightly can be installed through

$> npm install --save-exact wabt@nightly

or you can use one of the previous versions instead if necessary. Note the --save-exact when using a nightly.

Usage with a CDN

Replace VERSION with a specific version or omit it (not recommended in production) to use main/latest.

API

CLI

Node.js ports of the following command line tools are included in the package as well:

The tools can also be run ad hoc (without explicitly installing the package), for example with:

$> npx -p wabt wasm2wat myModule.wasm -o myModule.wat