npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@higayasuo/u8a-utils

v1.0.3

Published

A collection of utility functions for working with Uint8Arrays in TypeScript

Readme

u8a-utils

A collection of utility functions for working with Uint8Arrays in TypeScript.

Installation

npm install u8a-utils

Usage

import {
  concatUint8Arrays,
  compareUint8Arrays,
  uint64BE,
  writeUInt32BE,
  fromHex,
  toHex,
} from 'u8a-utils';

// Concatenate multiple Uint8Arrays
const arr1 = new Uint8Array([1, 2, 3]);
const arr2 = new Uint8Array([4, 5, 6]);
const result = concatUint8Arrays(arr1, arr2);
// result: Uint8Array [1, 2, 3, 4, 5, 6]

// You can also use the spread operator with an array
const arrays = [arr1, arr2];
const result2 = concatUint8Arrays(...arrays);
// result2: Uint8Array [1, 2, 3, 4, 5, 6]

// Compare two Uint8Arrays
const isEqual = compareUint8Arrays(arr1, arr2);
// isEqual: false

// Convert a number to a 64-bit Uint8Array in big-endian format
const uint64Value = uint64BE(0x1234567890000000);
// uint64Value: Uint8Array [18, 52, 86, 120, 144, 0, 0, 0]

// Write a 32-bit unsigned integer to a Uint8Array in big-endian format
const buf = new Uint8Array(4);
writeUInt32BE(buf, 0x12345678);
// buf: Uint8Array [18, 52, 86, 120]

// Convert Uint8Array to hexadecimal string
const hex = toHex(new Uint8Array([0x0a, 0x1b, 0x2c]));
// hex: "0a1b2c"

// Convert hexadecimal string to Uint8Array
const bytes = fromHex('0a1b2c');
// bytes: Uint8Array [10, 27, 44]

API

concatUint8Arrays(...arrays: Uint8Array[]): Uint8Array

Concatenates multiple Uint8Arrays into a single Uint8Array.

Parameters

  • ...arrays: Variable number of Uint8Arrays to concatenate

Returns

A new Uint8Array containing all the concatenated data

compareUint8Arrays(a: Uint8Array, b: Uint8Array): boolean

Compares two Uint8Arrays for equality.

Parameters

  • a: First Uint8Array to compare
  • b: Second Uint8Array to compare

Returns

true if the arrays are equal (same length and values), false otherwise

uint64BE(value: number): Uint8Array

Converts a 64-bit unsigned integer to a Uint8Array in big-endian format.

Parameters

  • value: The 64-bit unsigned integer to convert

Returns

A Uint8Array containing the 64-bit value in big-endian format

writeUInt32BE(u8array: Uint8Array, value: number, offset?: number): void

Writes a 32-bit unsigned integer to a Uint8Array in big-endian format.

Parameters

  • u8array: The Uint8Array to write to
  • value: The 32-bit unsigned integer to write
  • offset: The offset in the Uint8Array to start writing at (default: 0)

Throws

  • RangeError if the value is not in the range [0, MAX_INT32 - 1]

toHex(value: Uint8Array): string

Converts a Uint8Array to a hexadecimal string.

Parameters

  • value: The Uint8Array to convert

Returns

A string representing the hexadecimal value of the input Uint8Array

fromHex(value: string): Uint8Array

Converts a hexadecimal string to a Uint8Array.

Parameters

  • value: The hexadecimal string to convert

Returns

A Uint8Array representing the value of the input hexadecimal string

Throws

  • Error if the input string is not a valid hexadecimal string

Development

# Install dependencies
npm install

# Run tests
npm test

# Build the package
npm run build

License

ISC