Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@webassemblyjs/wasm-edit

Package Overview
Dependencies
Maintainers
1
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@webassemblyjs/wasm-edit

> Rewrite a WASM binary

  • 1.14.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
24M
decreased by-10.31%
Maintainers
1
Weekly downloads
 
Created

What is @webassemblyjs/wasm-edit?

The @webassemblyjs/wasm-edit package is a toolchain for WebAssembly that allows you to manipulate WASM binaries. It provides functionalities to parse, edit, and generate WASM binaries, making it useful for tasks such as optimizing, instrumenting, or simply understanding the structure of a WebAssembly module.

What are @webassemblyjs/wasm-edit's main functionalities?

Parsing WebAssembly binaries

This feature allows you to parse a WebAssembly binary and turn it into an Abstract Syntax Tree (AST) that can be manipulated or analyzed.

const { decode } = require('@webassemblyjs/wasm-parser');
const { readFileSync } = require('fs');

const wasmBuffer = readFileSync('module.wasm');
const ast = decode(wasmBuffer);

console.log(ast);

Modifying the AST

After parsing a WASM binary into an AST, you can traverse and modify the AST. This example shows how to change the module imports.

const { traverse } = require('@webassemblyjs/ast');

traverse(ast, {
  ModuleImport(path) {
    // Modify the AST by changing module imports
    path.node.module = 'new_module';
  }
});

Generating WebAssembly binaries

Once you have an AST—either from parsing a binary or constructing it manually—you can generate a new WebAssembly binary.

const { encode } = require('@webassemblyjs/wasm-gen');

const newWasmBuffer = encode(ast);

writeFileSync('modified.wasm', newWasmBuffer);

Other packages similar to @webassemblyjs/wasm-edit

FAQs

Package last updated on 06 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc