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

base28

v1.1.1

Published

Format sequential database ids as 6-character case-insensitive strings – ideal for URLs.

Downloads

3

Readme

base28

Represent your integer database ids as 6-character base-28 strings – an ideal format for URLs.

  • Maximum supported input is 0x0fffffff, i.e. 268,435,455.
  • Distributable size is 2.7kb, minified and gzipped.
  • Zero runtime dependencies.

Base28 Alphabet

This package's base28 encoding comprises of 8 numbers and 20 characters:

BCDFGHJKMN
PQRSTVWXYZ
23456789

or

bcdfghjkmn
pqrstvwxyz
23456789

These numbers and letters have been picked according to the criteria:

  • Encoded ids should typically look like ids - not words. This is achieved by omitting the vowels.
  • It should easy to visually distinguish between all characters - which is why 1 and 0 have been omitted - which can be confused with 'I' and 'O'.
  • It should be easy to communicate the characters through voice - thus lower and upper case characters can be used interchangeably.

Encoding

It's often undesireable for sequential ids to be readily identified as such. To avoid this, this encoding obfuscates your ids by applying a reversible pseudo-random looking mapping during encoding and decoding. For example:

0 -> GXBSXJ -> 0
1 -> PNPV8H -> 1
2 -> M3BXDH -> 2
3 -> TSP3GS -> 3

While this won't prevent any dedicated attackers from iterating through your ids, it will at least provide some protection against casual voyeurs.

Prior Art

Contributing

Pull requests would be appreciated for:

  • If you want to work with inputs greater than 268,435,455, it should be possible to extend this to work with 7 or 8-character strings.

  • Configuration of the obfuscator. In particular, it should be possible to pick configure the XOR and ROT numbers through a single large integer.

  • Much of the size of this library is due to a bundled, pared-down version of Google's BigInt polyfill. Exporting a second distributable with native BigInt would be a great pull request.

License

Copyright 2022, James K Nelson. Available for use under MIT License.