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

@pfeiferio/custom-base

v1.0.1

Published

Custom base encoding and decoding for numbers and BigInts using arbitrary charsets

Readme

@pfeiferio/custom-base

Custom base encoding and decoding for numbers and BigInts using arbitrary charsets.

This library allows you to encode and decode numeric values using any character set. It supports both JavaScript number and bigint types and is fully ESM-based with no dependencies.


Features

  • Encode / decode number and bigint
  • Arbitrary custom charsets
  • Built-in presets (base2, base16, base42, base128)
  • Cached and validated charset handling
  • Zero dependencies
  • Native Node.js test runner

Installation

npm install @pfeiferio/custom-base

Usage

Encoding and decoding numbers

import { encodeNumber, decodeNumber, presets } from '@pfeiferio/custom-base'

const encoded = encodeNumber(255, presets.base16)
const decoded = decodeNumber(encoded, presets.base16)

console.log(encoded) // "ff"
console.log(decoded) // 255

Encoding and decoding BigInts

import { encodeBigInt, decodeBigInt, presets } from '@pfeiferio/custom-base'

const value = 12345678901234567890n

const encoded = encodeBigInt(value, presets.base42)
const decoded = decodeBigInt(encoded, presets.base42)

console.log(decoded === value) // true

Custom charsets

You can provide your own charset as a string:

import { encodeNumber } from '@pfeiferio/custom-base'

const charset = 'ABCDEFG123456'
const encoded = encodeNumber(1337, charset)

Charset normalization

Internally, charsets are compiled, validated and cached. You can normalize inputs manually if needed:

import { ensureCharset, presets } from '@pfeiferio/custom-base'

const charset = ensureCharset(presets.base2)

The returned Charset object is immutable and guaranteed to be valid.


Presets

import { presets } from '@pfeiferio/custom-base'

presets.base2
presets.base16
presets.base42
presets.base128

All presets are non-standard and provided purely for convenience.


Node.js Support

  • Node.js ≥ 18
  • ESM only

License

MIT