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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@libn/base

v0.4.1

Published

Binary-to-text encoding.

Readme

@libn/base

Binary-to-text encoding.

b16

Base16 uses hexadecimal characters ("0-9" and "A-F"). Encoding is always uppercase (diverging from Number.prototype.toString and Uint8Array.prototype.toHex, which use lowercase "a-f"), and decoding is case-insensitive.

import { deB16, enB16 } from "@libn/base/b16";
import { assertEquals } from "@std/assert";

const binary = new TextEncoder().encode("Hello :)");
assertEquals(enB16(binary), "48656C6C6F203A29");
assertEquals(deB16("48656C6C6F203A29"), binary);

b32

Base32 uses uppercase letters and digits, excluding "0", "1", "8", and "9". Encoding is always uppercase, and decoding is case-insensitive.

import { deB32, enB32 } from "@libn/base/b32";
import { assertEquals } from "@std/assert";

const binary = new TextEncoder().encode("Hello :)");
assertEquals(enB32(binary), "JBSWY3DPEA5CS");
assertEquals(deB32("JBSWY3DPEA5CS"), binary);

h32

Base32hex uses digits and uppercase letters, excluding "W-Z". Encoding is always uppercase, and decoding is case-insensitive.

import { deH32, enH32 } from "@libn/base/h32";
import { assertEquals } from "@std/assert";

const binary = new TextEncoder().encode("Hello :)");
assertEquals(enH32(binary), "91IMOR3F40T2I");
assertEquals(deH32("91IMOR3F40T2I"), binary);

c32

Crockford base 32 uses digits and uppercase letters, excluding "I", "L", "O", and "U". Encoding is always uppercase, and decoding is case-insensitive, and additionally accepts hyphens (which don't affect the output) and substitutes "I", "L", and "O" characters for their similar-looking numeric counterparts ("1", "1", and "0", respectively).

import { deC32, enC32 } from "@libn/base/c32";
import { assertEquals } from "@std/assert";

const binary = new TextEncoder().encode("Hello :)");
assertEquals(enC32(binary), "91JPRV3F40X2J");
assertEquals(deC32("91JPRV3F40X2J"), binary);

b58

Base58 uses alphanumeric characters, excluding "0", "I", "O", and "l".

import { deB58, enB58 } from "@libn/base/b58";
import { assertEquals } from "@std/assert";

const binary = new TextEncoder().encode("Hello :)");
assertEquals(enB58(binary), "D7LMXYjUZJQ");
assertEquals(deB58("D7LMXYjUZJQ"), binary);

b64

Base64 uses alphanumeric characters and "+" and "/", and "=" for padding.

import { deB64, enB64 } from "@libn/base/b64";
import { assertEquals } from "@std/assert";

const binary = new TextEncoder().encode("Hello :)");
assertEquals(enB64(binary), "SGVsbG8gOik=");
assertEquals(deB64("SGVsbG8gOik="), binary);

u64

Base64url uses alphanumeric characters and "-" and "_". Padding is neither encoded nor decoded.

import { deU64, enU64 } from "@libn/base/u64";
import { assertEquals, assertMatch } from "@std/assert";

const binary = new TextEncoder().encode("Hello :)");
assertEquals(enU64(binary), "SGVsbG8gOik");
assertEquals(deU64("SGVsbG8gOik"), binary);

z85

Z85 uses printable, non-whitespace ASCII characters, excluding '"', "'", ",", ";", "\", "_", "`", "|", and "~". Unlike the original, the binary input length doesn't have to be a multiple of 4, the encoding and decoding functions add and remove padding automatically.

import { deZ85, enZ85 } from "@libn/base/z85";
import { assertEquals, assertMatch } from "@std/assert";

const binary = new TextEncoder().encode("Hello :)");
assertEquals(enZ85(binary), "nm=QNzY?7&");
assertEquals(deZ85("nm=QNzY?7&"), binary);

a85

Ascii85 uses the first 85 printable, non-whitespace ASCII characters, as well as "z" to compress sequences of 4 empty bytes. Unlike the original, the binary input length doesn't have to be a multiple of 4, the encoding and decoding functions add and remove padding automatically.

import { deA85, enA85 } from "@libn/base/a85";
import { assertEquals } from "@std/assert";

const binary = new TextEncoder().encode("Hello :)");
assertEquals(enA85(binary), "87cURD]h(i");
assertEquals(deA85("87cURD]h(i"), binary);