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

@endo/bytes

v1.0.0

Published

Portable Uint8Array helpers for cross-realm byte handling

Readme

@endo/bytes

@endo/bytes provides a minimal set of portable Uint8Array helpers for cross-realm byte handling. Endo runs in three byte-handling realms: Node (where Buffer is ambient), XS (no Buffer), and SES-locked compartments (where Uint8Array is the only portable byte container). This package is the canonical home for the Uint8Array helpers that those realms share.

Install

npm install @endo/bytes

Usage

import { bytesFromText } from '@endo/bytes/from-string.js';
import { bytesToText } from '@endo/bytes/to-string.js';
import { concatBytes } from '@endo/bytes/concat.js';
import { bytesEqual } from '@endo/bytes/equals.js';
import { bytesToImmutable } from '@endo/bytes/to-immutable.js';
import { bytesFromImmutable } from '@endo/bytes/from-immutable.js';

const a = bytesFromText('Hello, ');
const b = bytesFromText('world!');
const greeting = concatBytes([a, b]);
bytesToText(greeting); // 'Hello, world!'

bytesEqual(bytesFromText('abc'), bytesFromText('abc')); // true

// Wrap a Uint8Array in a passable, immutable ArrayBuffer.
const passable = bytesToImmutable(greeting);
// Recover a working Uint8Array from an immutable buffer received over a vat boundary.
bytesToText(bytesFromImmutable(passable)); // 'Hello, world!'

The package is exported as per-symbol subpath modules so that callers import qualified names without needing a namespace import.

API

concatBytes(chunks) -> Uint8Array

Concatenates a list of Uint8Array chunks into a single contiguous Uint8Array. Empty input yields an empty Uint8Array.

bytesEqual(a, b) -> boolean

Compares two Uint8Array values byte-for-byte. Returns true when the two arrays have equal length and equal contents.

bytesFromText(s) -> Uint8Array

Encodes a string as UTF-8 bytes.

bytesToText(view) -> string

Decodes UTF-8 bytes to a string.

bytesToImmutable(view) -> ArrayBuffer

Wraps a Uint8Array view's contents in an immutable ArrayBuffer via the ArrayBuffer.prototype.sliceToImmutable shim (proposal-immutable-arraybuffer). The result carries the 'byteArray' passStyle and is hardened, so it is safe to share across vat boundaries. The view's byteOffset and byteLength are honored, so subarray windows copy only the addressed bytes.

bytesFromImmutable(buffer) -> Uint8Array

Copies the contents of an immutable ArrayBuffer into a fresh, mutable Uint8Array. Immutable ArrayBuffer instances cannot back a Uint8Array view directly and APIs such as TextDecoder.decode reject them; this helper produces a working Uint8Array copy that callers can pass to those APIs.

Out of scope

For other byte operations, prefer existing packages or built-in methods.

  • Slicing: use Uint8Array.prototype.subarray (no copy) or Uint8Array.prototype.slice (copy).
  • Hex encoding and decoding: use @endo/hex.
  • Base64 encoding and decoding: use @endo/base64.
  • Streaming concatenation: compose concatBytes with a for await loop; see @endo/stream and @endo/stream-node for stream primitives.

Hardened JavaScript

Every export is hardened. The TextEncoder and TextDecoder instances backing bytesFromText and bytesToText are captured once at module load, so post-lockdown mutation of the corresponding globals cannot redirect the dispatched calls. The modules have no other mutable state.