wabt.js is a port of WABT, the WebAssembly Binary Toolkit, to the Web.
$> 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);
-
parseWast(filename:
string
, buffer:string | Uint8Array
):WasmModule
Parses a wast source to a module. -
readWasm(buffer:
Uint8Array
, options:IReadWasmOptions
):WasmModule
Reads a wasm binaryen to a module. -
WasmModule
A class representing a WebAssembly module.- generateNames():
void
Generates textual names for function types, globals, labels etc. - applyNames():
void
Applies textual names. - toText(options:
IToTextOptions
):string
Converts the module to wast text format. - toBinary(options:
IToBinaryOptions
):IToBinaryResult
Converts the module to a wasm binary. - destroy():
void
Disposes the module and frees its resources.
- generateNames():
-
IReadWasmOptions
Options modifying the behavior ofreadWasm
.- readDebugNames:
boolean
Reads textual names from the name section.
- readDebugNames:
-
IToTextOptions
Options modifying the behavior ofWasmModule#toText
.- foldExprs:
boolean
- inlineExport:
boolean
- foldExprs:
-
IToBinaryOptions
Options modifying the behavior ofWasmModule#toBinary
.- log:
boolean
- canonicalize_lebs:
boolean
- relocatable:
boolean
- write_debug_names:
boolean
- log:
-
IToBinaryResult
Result object ofWasmModule#toBinary
.-
buffer:
Uint8Array
The wasm binary buffer. -
log:
string
Generated log output.
-