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

@webassemblyjs/helper-wasm-section

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/helper-wasm-section

  • 1.7.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is @webassemblyjs/helper-wasm-section?

The @webassemblyjs/helper-wasm-section package is part of the WebAssemblyJS project and provides utility functions for manipulating sections in WebAssembly (Wasm) binary files. It allows developers to parse, add, or modify sections within a Wasm binary, which can be useful for tasks such as Wasm optimization, analysis, or transformation.

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

Parsing a Wasm section

This feature allows you to parse a specific section of a WebAssembly binary. The code sample demonstrates how to use the `getSectionMetadata` function to retrieve metadata for the 'type' section of a Wasm binary.

const { decode } = require('@webassemblyjs/wasm-parser');
const { getSectionMetadata } = require('@webassemblyjs/helper-wasm-section');

const wasmBuffer = ...; // A buffer containing the Wasm binary
const ast = decode(wasmBuffer);
const typeSectionMetadata = getSectionMetadata(ast, 'type');

Adding a new Wasm section

This feature allows you to add a new section to a WebAssembly binary. The code sample shows how to use the `addSection` function to add a new section to the AST of a Wasm binary and then encode it back into a binary format.

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

const ast = ...; // The AST of a Wasm binary
const newSection = ...; // The new section to add
addSection(ast, newSection);
const newWasmBuffer = encode(ast);

Modifying an existing Wasm section

This feature allows you to modify the content of an existing section in a WebAssembly binary. The code sample illustrates how to use the `editSection` function to change the content of the 'code' section in the AST and then encode the modified AST back into a binary.

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

const ast = ...; // The AST of a Wasm binary
const sectionName = 'code';
const newContent = ...; // The new content for the section
editSection(ast, sectionName, newContent);
const newWasmBuffer = encode(ast);

Other packages similar to @webassemblyjs/helper-wasm-section

FAQs

Package last updated on 19 Jul 2018

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