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

id64

v1.3.5

Published

Generate short, globally unique, time-sortable, url-safe, lexicographically stable string identifiers.

Downloads

300

Readme

id64

Javascript library that generates short identifiers that are time-sortable, url-safe, lexicographically stable, and globally unique.

The identifiers are composed from the characters:

[A-Z][a-z][0-9]_\.

We first generate a v1 uuid with Kelektiv's node-uuid library. We then shift the bits around to make it time sortable and finally encode it with Dominic Tarr's very cool d64. The result is a time sortable, globally unique, lexicographically, stable, url-safe, identifier that is 22 characters long. If you don't care about recovering the underlying uuid, the generated identifier can be reduced to 20 characters.

Install

With yarn:

yarn add id64

With npm:

npm install id64

Usage

For ES5 environments:

var id64 = require('id64');
var id = id64.gen();

For ES6+ environments:

import id64 from 'id64';
const id = id64.gen();

This will return a 22-character id like: 3Ti0cL9b_Z1w0mTZvpk0WF.

UUIDs

You can recover the original v1 UUID encoded in the generated id64 id, as well as the time embedded in that uuid in several formats.

const myID = id64.gen(); // eg, 3Ti0dNwMcl1ojbBHgw3W2.
const origUUID = id64.ungen(myID); // eg, 8f17a310-81a5-11eb-b4be-7312b3c1210c

You can also recover the underlying timestamp of the id in several formats:

const id     = id64.gen();
                                // timestamp of the id as...
const ticks  = id64.ticks(id);  // 100-nanonsecond intervals since gregorian epoch
const micros = id64.micros(id); // microseconds since unix epoch
const millis = id64.millis(id); // milliseconds since unix epoch
const date   = id64.date(id);   // a javascript Date

If you don't care about recovering the underlying UUID, you can get a shorter, 20-character id64 identifier by passing false to the gen() function:

const shorterID = id64.gen(false); // eg, 3Ti0d_i1Fv0x9uTON9YK