Socket
Socket
Sign inDemoInstall

@stablelib/bytes

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stablelib/bytes

Byte utilities


Version published
Weekly downloads
324K
decreased by-3.23%
Maintainers
1
Weekly downloads
 
Created

What is @stablelib/bytes?

@stablelib/bytes is a utility library for working with byte arrays in JavaScript. It provides a variety of functions for manipulating and converting byte arrays, making it easier to handle binary data.

What are @stablelib/bytes's main functionalities?

Concatenation

This feature allows you to concatenate multiple byte arrays into a single byte array.

const bytes = require('@stablelib/bytes');
const array1 = new Uint8Array([1, 2, 3]);
const array2 = new Uint8Array([4, 5, 6]);
const concatenated = bytes.concat(array1, array2);
console.log(concatenated); // Uint8Array [1, 2, 3, 4, 5, 6]

Equality Check

This feature allows you to check if two byte arrays are equal.

const bytes = require('@stablelib/bytes');
const array1 = new Uint8Array([1, 2, 3]);
const array2 = new Uint8Array([1, 2, 3]);
const isEqual = bytes.equal(array1, array2);
console.log(isEqual); // true

Subarray Extraction

This feature allows you to extract a subarray from a given byte array.

const bytes = require('@stablelib/bytes');
const array = new Uint8Array([1, 2, 3, 4, 5]);
const subarray = bytes.subarray(array, 1, 3);
console.log(subarray); // Uint8Array [2, 3]

Hex Encoding/Decoding

This feature allows you to encode a byte array to a hex string and decode a hex string back to a byte array.

const bytes = require('@stablelib/bytes');
const array = new Uint8Array([1, 2, 3]);
const hexString = bytes.toHex(array);
console.log(hexString); // '010203'
const decodedArray = bytes.fromHex(hexString);
console.log(decodedArray); // Uint8Array [1, 2, 3]

Other packages similar to @stablelib/bytes

FAQs

Package last updated on 21 May 2021

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