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

uint8-base64

v1.0.0

Published

Encode and decode base64 to and from Uint8Array

Downloads

31,429

Readme

uint8-base64

NPM version build status Test coverage npm download

You can find a lot of NPM libraries dealing with base64 encoding and decoding.

However, we could not find one that would have as input AND output an Uint8Array. This library does exactly this.

This library is pretty fast and will convert over 500 Mb per second in NodeJS as well as in the browser.

If you need at the end a text rather than an Uint8Array it is also extremely fast to convert the Uint8Array to text using a TextEncoder:

const base64 = encode(bytes);
const string = new TextDecoder('utf8').decode(base64);

Installation

$ npm i uint8-base64

Usage

encode

import { encode } from 'uint8-base64';

const result = encode(Uint8Array.from([65])); // an array containing 'A'
// result is Uint8Array(4) [ 81, 81, 61, 61 ] ('QQ==')

Encoding to text speed test

import { encode } from 'uint8-base64';

const bytes = new Uint8Array(256 * 1024 * 1024).map((_, i) =>
  Math.floor(Math.random() * 256),
);

console.time('base64');
const base64 = encode(bytes);
const string = new TextDecoder('utf8').decode(base64);
console.timeEnd('base64');

console.log(string.slice(0, 100));

This code takes 330ms on my MacBook pro M4 to encode 256Mb of data. The encoding itself takes 240ms while the conversion to text takes 50ms.

decode

import { decode } from '..';

const result = decode(Uint8Array.from([81, 81, 61, 61])); // an array containing 'QQ=='
// result is Uint8Array(1) [ 65 ] ('A')

License

The code was largely inspired by: https://gist.github.com/enepomnyaschih/72c423f727d395eeaa09697058238727

MIT