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

scru64

v1.0.1

Published

SCRU64: Sortable, Clock-based, Realm-specifically Unique identifier

Downloads

16

Readme

SCRU64: Sortable, Clock-based, Realm-specifically Unique identifier

npm License

SCRU64 ID offers compact, time-ordered unique identifiers generated by distributed nodes. SCRU64 has the following features:

  • 63-bit non-negative integer storable as signed/unsigned 64-bit integer
  • Sortable by generation time (as integer and as text)
  • 12-digit case-insensitive textual representation (Base36)
  • ~38-bit Unix epoch-based timestamp that ensures useful life until year 4261
  • Variable-length node/machine ID and counter fields that share 24 bits
// pass node ID through global variable
globalThis.SCRU64_NODE_SPEC = "42/8";

import { scru64Sync, scru64StringSync } from "scru64";
// or on browsers:
// import { scru64Sync, scru64StringSync } from "https://unpkg.com/scru64@^1";

// generate a new identifier object
const x = scru64Sync();
console.log(String(x)); // e.g., "0u2r85hm2pt3"
console.log(x.toBigInt()); // as a 64-bit unsigned integer

// generate a textual representation directly
console.log(scru64StringSync()); // e.g., "0u2r85hm2pt4"

See SCRU64 Specification for details.

SCRU64's uniqueness is realm-specific, i.e., dependent on the centralized assignment of node ID to each generator. If you need decentralized, globally unique time-ordered identifiers, consider SCRU128.

Command-line interface

$ SCRU64_NODE_SPEC=42/8 npx scru64
0uc3xnefo50h
$ SCRU64_NODE_SPEC=42/8 npx scru64 -n 4
0uc3xnl3eas9
0uc3xnl3easa
0uc3xnl3easb
0uc3xnl3easc

License

Licensed under the Apache License, Version 2.0.

See also