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

@orkestrel/codec

v0.0.4

Published

Spec-named byte-to-text codings and their measures as sound encode/decode/guard triples — RFC 4648 Base64, base64url, and hex, UTF-8, Latin-1, Windows-1252, and UTF-16LE — pure ES and canonical in both directions.

Readme

@orkestrel/codec

The fleet's byte-to-text codings: sound encode / decode / guard triples over string and Uint8Array for RFC 4648 Base64, base64url, and hex and for the UTF-8, ISO-8859-1, Windows-1252, and UTF-16LE charsets, beside a measure* that answers a coding's byte-side size question without producing those bytes.

Import the face you need from @orkestrel/codec and call it: every export is a plain function over string and Uint8Array, with no options bag, no class, and no error type. Runtime type tests come from @orkestrel/contract. A decoder reports refusal as undefined and a guard reports it as false, so there is nothing to catch and nothing to configure. Source: src/core. Part of the @orkestrel line.

Install

npm install @orkestrel/codec

Requirements

  • Node.js >= 22.12.0, matching the engines field in package.json
  • ESM and CommonJS entry points, selected by the exports field in package.json
  • Runtime dependency: @orkestrel/contract

The RFC 4648 faces and their guards are the guide's Codings section, and the byte-side sizes beside them are its Measures section.

A charset's wire form is bytes rather than text, so its encode* takes a string and its decode* takes bytes. The laws are unchanged; only the direction each is written in inverts. Those faces are the guide's Charsets section.

The round-trip law. decode*(encode*(value)) deep-equals value, for every input the coding admits, the empty one included.

The canonical-form law. encode*(decode*(wire)) returns wire, for every wire form the face's guard admits.

The sound-triple law. A measure equals the length of the bytes the function producing them would return, for every string — the admitted texts pinning a length, the refused ones pinning undefined on both sides. The producer is the decoder where the wire form is text, so measureBase64(text) === decodeBase64(text)?.length, and the encoder where the wire form is bytes, so measureUTF8(text) === encodeUTF8(text)?.length.

computeBytes in @orkestrel/scaffold counts UTF-8 bytes too, and it answers a different question for a lone surrogate: the three bytes TextEncoder writes for the replacement character, where measureUTF8 answers undefined. That divergence is deliberate — it is the strict door this package keeps on every face — and a consumer wanting the replacement count calls the counter that produces it.

RFC 4648 §8 prints its table uppercase; this package's canonical spelling is lowercase, matching every producer the fleet already reads. One canonical spelling per input is the charter's law, so decodeHex('AB') is undefined and encodeHex(new Uint8Array([0xab])) is 'ab'.

The charsets part from the platform's own codings where the guide names it: the WHATWG latin1 label is windows-1252 rather than ISO-8859-1, the WHATWG windows-1252 index defines the slots this code page leaves undefined, and a fatal TextDecoder strips a leading BOM that this package's round-trip law keeps.

import { decodeBase64, encodeBase64, isBase64 } from '@orkestrel/codec'

decodeBase64('aa==') // undefined — the unused trailing bits are not zero
decodeBase64('aQ==') // Uint8Array [105] — the canonical spelling of that byte
encodeBase64(new Uint8Array([105])) // 'aQ=='
decodeBase64('AQ D') // undefined — whitespace
decodeBase64('A') // undefined — a length off the group boundary
decodeBase64('AQID=') // undefined — padding off the group boundary
decodeBase64('-_-_') // undefined — the url alphabet
isBase64('aa==') // false

See guides/codec.md in this repository for the membership bar and the full doctrine.