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 🙏

© 2024 – Pkg Stats / Ryan Hefner

encode32

v1.1.0

Published

encoding utility for integers inspired by Crockford Base32

Downloads

40,691

Readme

encode32

This is a Base-32 encoding for 32-bit numbers inspired by Douglas Crockford

http://www.crockford.com/wrmg/base32.html

This encoding is designed to balance compactness with human-friendliness and robustness. It uses 32 digits, the standard numbers and 22 alphabetic characters. It is case insensitive and characters easily confused by humans are accepted as aliases for some digits (e.g. l and I for 1, o for 0, etc). U is excluded so you can avoid winding up with certain common obscenities.

A 32-bit unsigned integer will encode into 7 base-32 (5-bit) digits (left padded with 0 as needed). Rather than use an additional check character as suggested in the original source, we fill the otherwise unused bits of the final character to with a 3-bit parity checksum. This feature makes it incompatible with other encoding schemes, but allows for quick sanity checks for transcribed numbers without the increased length or additional alphabet required by Crockford's "mod 37 checksum" approach.

Install

npm install encode32

or

git clone http://github.com/femto113/node-encode32.git
cd encode32
npm link

Example

var enc = require("./encode32");

var a = enc.encode32(123456772);
// a == "0XDWT16"

// can change case or substitute 1's and 0's without problem
var b = [
  "0xdwt16", // lower case
  "oXDWTi6", // o for 0 and i for 1
  "OxDwtL6"  // O for 0 and L for 1
].map(function (s) { return enc.decode32(s); });
// b == [123456772, 123456772, 123456772]

// but break the parity check and you get NaN
var c = [
  "0XDWT18", // incorrect final digit
  "X0DWT16", // transposed digits
  "0XDT16"   // missing digit
].map(function (s) { return enc.decode32(s); });
// c == [NaN, NaN, NaN]

console.log(a, b, c);

TODO

  • needs performance work (probably should port to C++)
  • should provide versions without parity bits and with checksum for compatibility with other implementations