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 🙏

© 2026 – Pkg Stats / Ryan Hefner

apexid

v1.1.2

Published

Zero-dependency, 136-bit, lexicographically sortable ID generator with Base62 encoding and 16-bit CRC checksum.

Readme

apexid

Zero-dependency, 136-bit, lexicographically sortable ID generator with Base62 encoding and a 16-bit CRC checksum.

Features

  • Lexicographically sortable: Generated IDs sort chronologically when sorted alphabetically.
  • Tamper-evident: Features a 16-bit CRC checksum to validate integrity and reject corrupted or modified IDs.
  • Monotonicity: Guarantees ascending order even when multiple IDs are generated within the same millisecond.
  • Clock skew mitigation: Automatically handles system clock drift/rewind.
  • CSPRNG entropy: Employs cryptographically secure random numbers for the random component.
  • Base62 encoded: Yields clean, url-safe, alphanumeric 23-character strings.
  • Zero external dependencies.

Installation

npm install apexid

Usage

Generating IDs

import { ApexIdGenerator } from 'apexid';

const generator = new ApexIdGenerator();
const id = generator.generate();

console.log(id); // Example: "01H2Z4J6K8M0NPQ2R4S6T8V"

Validating IDs

Validation checks the length, characters (Base62), and verifies the embedded checksum.

import { ApexIdGenerator } from 'apexid';

const isValid = ApexIdGenerator.validate('01H2Z4J6K8M0NPQ2R4S6T8V');
console.log(isValid); // true

ID Structure

An ApexID is represented as a 23-character Base62 string (136 bits total). Internally, it is structured as follows:

  • Timestamp (48 bits): UNIX epoch timestamp in milliseconds, stored in big-endian byte order to enable chronological sorting.
  • Sequence/Counter (8 bits): Tracks monotonicity for IDs generated in the exact same millisecond. Automatically shifts the timestamp forward if more than 255 IDs are generated in a millisecond.
  • Entropy (64 bits): Cryptographically secure random bytes to prevent collisions.
  • Checksum (16 bits): CRC16-CCITT checksum computed over the timestamp, counter, and entropy bytes to verify authenticity and integrity.

API Reference

ApexIdGenerator

The main class to generate and validate IDs.

new ApexIdGenerator()

Creates a new instance of the generator. Each instance maintains its own internal state for timestamp tracking and monotonic counters to ensure sorting guarantees.

generate(): string

Generates a strictly 23-character Base62 string.

static validate(id: string): boolean

Performs validation on the given string:

  • Checks if the string is exactly 23 characters long.
  • Decodes the Base62 structure and ensures no invalid characters are present.
  • Verifies that the internal 16-bit CRC-16 checksum matches the payload bytes.

Utility Functions

The package also exports underlying utility functions if you need direct access to the byte manipulation layer.

import {
  calculateChecksum,
  encodeBase62,
  decodeBase62,
  getRandomBytes
} from 'apexid';

calculateChecksum(buffer: Uint8Array): number

Calculates the 16-bit CRC-16 checksum of a Uint8Array.

encodeBase62(buffer: Uint8Array): string

Encodes a Uint8Array into a Base62 string.

decodeBase62(str: string): Uint8Array

Decodes a Base62 string back into a Uint8Array.

getRandomBytes(size: number): Uint8Array

Generates a Uint8Array of the specified size containing cryptographically secure random bytes.

License

MIT