Socket
Socket
Sign inDemoInstall

@webassemblyjs/leb128

Package Overview
Dependencies
1
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Install Socket

Protect your apps from supply chain attacks

Install

@webassemblyjs/leb128

LEB128 decoder and encoder

    1.11.6latest
    GitHub
    npm

Version published
Maintainers
1
Weekly downloads
22,615,245
increased by3.94%

Weekly downloads

Package description

What is @webassemblyjs/leb128?

The @webassemblyjs/leb128 package is a utility library for encoding and decoding LEB128 (Little Endian Base 128) values. LEB128 is a variable-length encoding for arbitrary-precision integers, commonly used in the WebAssembly binary format. This package provides functions to read and write both signed and unsigned LEB128 integers.

What are @webassemblyjs/leb128's main functionalities?

Decode unsigned LEB128

This feature allows you to decode an unsigned LEB128 integer from a buffer. The provided code sample demonstrates how to decode a buffer containing an unsigned LEB128 encoded integer.

const { decodeU32 } = require('@webassemblyjs/leb128');
const buffer = Buffer.from([0xe5, 0x8e, 0x26]);
const result = decodeU32(buffer); // result is 624485

Decode signed LEB128

This feature allows you to decode a signed LEB128 integer from a buffer. The provided code sample demonstrates how to decode a buffer containing a signed LEB128 encoded integer.

const { decodeS32 } = require('@webassemblyjs/leb128');
const buffer = Buffer.from([0x9b, 0xf1, 0x59]);
const result = decodeS32(buffer); // result is -624485

Encode unsigned LEB128

This feature allows you to encode an unsigned integer into LEB128 format. The provided code sample demonstrates how to encode a JavaScript number into an unsigned LEB128 buffer.

const { encodeU32 } = require('@webassemblyjs/leb128');
const value = 624485;
const buffer = encodeU32(value); // buffer is <Buffer e5 8e 26>

Encode signed LEB128

This feature allows you to encode a signed integer into LEB128 format. The provided code sample demonstrates how to encode a JavaScript number into a signed LEB128 buffer.

const { encodeS32 } = require('@webassemblyjs/leb128');
const value = -624485;
const buffer = encodeS32(value); // buffer is <Buffer 9b f1 59>

Other packages similar to @webassemblyjs/leb128

FAQs

Last updated on 09 May 2023

Did you know?

Socket installs a GitHub app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc