Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
uint8arrays
Advanced tools
The uint8arrays npm package provides utilities for working with Uint8Array objects in JavaScript. It includes functions for concatenation, comparison, conversion to and from strings, and more.
Concatenation
This feature allows you to concatenate multiple Uint8Array objects into a single Uint8Array.
const uint8arrays = require('uint8arrays');
const arr1 = new Uint8Array([1, 2, 3]);
const arr2 = new Uint8Array([4, 5, 6]);
const concatenated = uint8arrays.concat([arr1, arr2]);
console.log(concatenated); // Uint8Array [1, 2, 3, 4, 5, 6]
Comparison
This feature allows you to compare two Uint8Array objects for equality.
const uint8arrays = require('uint8arrays');
const arr1 = new Uint8Array([1, 2, 3]);
const arr2 = new Uint8Array([1, 2, 3]);
const arr3 = new Uint8Array([4, 5, 6]);
console.log(uint8arrays.equals(arr1, arr2)); // true
console.log(uint8arrays.equals(arr1, arr3)); // false
Conversion to and from Strings
This feature allows you to convert Uint8Array objects to and from strings using various encodings.
const uint8arrays = require('uint8arrays');
const arr = new Uint8Array([72, 101, 108, 108, 111]);
const str = uint8arrays.toString(arr, 'utf8');
console.log(str); // 'Hello'
const newArr = uint8arrays.fromString('Hello', 'utf8');
console.log(newArr); // Uint8Array [72, 101, 108, 108, 111]
The buffer package provides a way of handling binary data in Node.js. It includes many similar functionalities to uint8arrays, such as concatenation, comparison, and conversion to and from strings. However, buffer is more tightly integrated with Node.js and provides additional features like reading and writing to files.
The typedarray package provides polyfills for JavaScript's typed array functionality, including Uint8Array. While it doesn't offer as many utility functions as uint8arrays, it ensures compatibility with older JavaScript environments that do not support typed arrays natively.
Utility functions to make dealing with Uint8Arrays easier
$ npm i uint8arrays
<script>
tagLoading this module through a script tag will make it's exports available as Uint8arrays
in the global namespace.
<script src="https://unpkg.com/uint8arrays/dist/index.min.js"></script>
Licensed under either of
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
FAQs
Utility functions to make dealing with Uint8Arrays easier
The npm package uint8arrays receives a total of 830,209 weekly downloads. As such, uint8arrays popularity was classified as popular.
We found that uint8arrays demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.