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

bufferbase

v2.0.0

Published

Buffer-to-BaseN Encoder, Decoder, Converter, and Validator

Readme

bufferbase

Buffer-to-BaseN encoding and decoding for Node.js.

Installation

npm install bufferbase

Usage

Simple Function API

import { encode, decode, convert, validate } from 'bufferbase';

// Encode buffer to base58
const encoded = encode(Buffer.from('Hello'), 'base58');

// Decode base58 string to buffer
const decoded = decode(encoded, 'base58');

// Decode with fixed size (pads with leading zeros)
const fixed = decode(encoded, 'base58', { size: 32 });

// Convert between bases
const base64 = convert(encoded, 'base58', 'base64url');

// Validate string
validate('9Ajdvz', 'base58'); // true
validate('0Ajdvz', 'base58'); // false ('0' not in base58)

Pre-defined Codecs

import { Codecs } from 'bufferbase';

const encoded = Codecs.base58.encode(Buffer.from('Hello'));
const decoded = Codecs.base58.decode(encoded);

// Convert between codecs
const base64 = Codecs.base58.convertTo(Codecs.base64url, encoded);

// Validate
Codecs.base58.validate('9Ajdvz'); // true

Custom Character Set

import { createCodec } from 'bufferbase';

const binary = createCodec('01');
binary.encode(Buffer.from([5])); // '101'
binary.decode('101'); // Buffer([5])

Supported Encodings

| Name | Characters | |------|------------| | decimal | 0-9 | | base16 / hex | 0-9A-F | | base32 | A-Z2-7 | | base32crockford | 0-9A-HJKMNP-TV-Z | | base36 | 0-9A-Z | | base52 | A-Za-z | | base58 | Bitcoin alphabet (no 0OIl) | | base64 | A-Za-z0-9+/ | | base64url | A-Za-z0-9-_ | | base64xml | A-Za-z0-9._ | | base64xmlname | A-Za-z0-9_: | | ascii85 | ASCII85 | | base85 | Base85 | | z85 | ZeroMQ Z85 |

API

Functions

  • encode(buffer, base) - Encode buffer to string
  • decode(encoded, base, options?) - Decode string to buffer
  • convert(input, from, to) - Convert between bases
  • validate(input, base) - Check if string is valid for base
  • createCodec(chars) - Create codec with custom character set

Codecs Object

Codecs.base58.encode(buffer)
Codecs.base58.decode(encoded, options?)
Codecs.base58.validate(input)
Codecs.base58.convertTo(targetCodec, input)

Options

interface DecodeOptions {
  size?: number; // Expected buffer size (pads with zeros if smaller)
}

Errors

  • InvalidCharacterError - Invalid character in decode input
  • BufferSizeError - Decoded buffer exceeds specified size
  • UnknownBaseError - Unknown base name

License

ISC