wabt.js

A buildbot for wabt.js, a port of WABT to the Web, with TypeScript support.

Github stars Tracking Chart

wabt.js

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

npm npm Build Status

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, options?: WasmFeatures): WasmModule
    Parses a wst source to a module.

  • readWasm(buffer: Uint8Array, options: ReadWasmOptions & WasmFeatures): 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.
  • ReadWasmOptions
    Options modifying the behavior of readWasm.

    • readDebugNames: boolean
      Reads textual names from the name section.
  • ToTextOptions
    Options modifying the behavior of WasmModule#toText.

    • foldExprs: boolean
    • inlineExport: boolean
  • ToBinaryOptions
    Options modifying the behavior of WasmModule#toBinary.

    • log: boolean
    • canonicalize_lebs: boolean
    • relocatable: boolean
    • write_debug_names: boolean
  • ToBinaryResult
    Result object of WasmModule#toBinary.

    • buffer: Uint8Array
      The wasm binary buffer.
    • log: string
      Generated log output.
  • WasmFeatures
    Post-MVP WebAssembly features to legalize.

    • exceptions: boolean
      Exception handling (proposal).
    • mutable_globals: boolean
      Import/Export mutable globals (proposal).
    • sat_float_to_int: boolean
      Non-trapping Float-to-int Conversions (proposal).
    • sign_extension: boolean
      Sign-extension operators (proposal).
    • simd: boolean
      128-bit packed SIMD (proposal).
    • threads: boolean
      Threading (proposal).
    • multi_value: boolean
      Multi-value (proposal).
    • tail_call: boolean
      Tail Call (proposal).
    • bulk_memory: boolean
      Bulk Memory Operations and Conditional Segment Initialization (proposal).
    • reference_types: boolean
      Reference Types (proposal).
    • annotations: boolean
      Custom Annotation Syntax for the Wasm Text Format (proposal).

Main metrics

Overview
Name With OwnerAssemblyScript/wabt.js
Primary LanguageJavaScript
Program languageJavaScript (Language Count: 3)
Platform
License:Apache License 2.0
所有者活动
Created At2017-06-22 10:04:32
Pushed At2025-06-07 01:18:52
Last Commit At
Release Count532
Last Release Namev1.0.37-nightly.20250607 (Posted on )
First Release Namev0.0.13 (Posted on )
用户参与
Stargazers Count161
Watchers Count6
Fork Count14
Commits Count604
Has Issues Enabled
Issues Count35
Issue Open Count7
Pull Requests Count6
Pull Requests Open Count2
Pull Requests Close Count10
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private