Package Exports
- wabt
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (wabt) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
wabt.js
wabt.js is a port of WABT to the Web, allowing you to manipulate WebAssembly modules using a JavaScript API.
Usage
$> npm install wabt
var wabt = require("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 wabt@nightly
or you can use one of the previous versions instead if necessary.
Usage with a CDN
- From GitHub via jsDelivr:
https://cdn.jsdelivr.net/gh/AssemblyScript/wabt.js@VERSION/index.js
- From npm via jsDelivr:
https://cdn.jsdelivr.net/npm/wabt@VERSION/index.js
- From npm via UNPKG:
https://unpkg.com/wabt@VERSION/index.js
Replace VERSION
with a specific version or omit it (not recommended in production) to use master/latest.
API
parseWat(filename:
string
, buffer:string | Uint8Array
):WasmModule
Parses a wst source to a module.readWasm(buffer:
Uint8Array
, options:ReadWasmOptions
):WasmModule
Reads a wasm binaryen to a module.WasmModule
A class representing a WebAssembly module.- validate():
void
Validates the module. Throws if not valid. - resolveNames():
void
Resolves names to indexes. - generateNames():
void
Generates textual names for function types, globals, labels etc. - applyNames():
void
Applies textual names. Throws on error. - toText(options:
ToTextOptions
):string
Converts the module to wat text format. - toBinary(options:
ToBinaryOptions
):ToBinaryResult
Converts the module to a wasm binary. - destroy():
void
Disposes the module and frees its resources.
- validate():
ReadWasmOptions
Options modifying the behavior ofreadWasm
.- readDebugNames:
boolean
Reads textual names from the name section.
- readDebugNames:
ToTextOptions
Options modifying the behavior ofWasmModule#toText
.- foldExprs:
boolean
- inlineExport:
boolean
- foldExprs:
ToBinaryOptions
Options modifying the behavior ofWasmModule#toBinary
.- log:
boolean
- canonicalize_lebs:
boolean
- relocatable:
boolean
- write_debug_names:
boolean
- log:
ToBinaryResult
Result object ofWasmModule#toBinary
.buffer:
Uint8Array
The wasm binary buffer.log:
string
Generated log output.