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

uniqigen

v1.0.0

Published

Cryptographically secure unique ID generator.

Readme

uniqigen

Cryptographically secure unique ID generator — configurable length, multiple formats, zero duplicates.

Better than UUID when you need short, custom-length identifiers that never collide.

Why uniqigen over UUID?

| Feature | UUID v4 | uniqigen | |---------|---------|----------| | Length | Fixed 36 chars | You choose (6, 10, 20...) | | Format | Hex + dashes | Numeric, alphanumeric, hex, base62 | | Sortable | No | Yes (generateSortable) | | Duplicate guarantee | Probabilistic | Built-in registry (createUniqueGenerator) | | Short OTP / order numbers | Awkward | Native (generateNumber(6)) |

Install

npm install uniqigen

Quick Start

import { generateNumber, generate, createUniqueGenerator } from "uniqigen";

// 6-digit random number (OTP, PIN, short code)
const otp = generateNumber(6);        // "482917"

// 10-char alphanumeric ID
const orderId = generate({ length: 10 });  // "kR3mP9xL2n"

// Guaranteed unique — never repeats in your app
const gen = createUniqueGenerator({ length: 8, charset: "numeric" });
const ticket1 = gen.next();  // "38472910"
const ticket2 = gen.next();  // "10293847" — always different

API

generate(options?)

Main generator with full control.

generate({ length: 10 })                          // default alphanumeric
generate({ length: 6, charset: "numeric" })       // "482917"
generate({ length: 12, charset: "hex" })          // hex string
generate({ length: 8, prefix: "USR-" })           // "USR-kR3mP9xL"
generate({ length: 6, customCharset: "ABC123" })  // custom pool

Charsets: "numeric" | "alphanumeric" | "hex" | "base62"

Shortcuts

generateNumber(6)        // "482917"
generateAlphanumeric(10) // "kR3mP9xL2n"
generateHex(32)          // 32-char hex
generateBase62(10)       // URL-safe compact ID
generateSortable(8)      // timestamp + random (sortable)

createUniqueGenerator(options?)

Session-level duplicate prevention — retries automatically if collision detected.

const gen = createUniqueGenerator({ length: 6, charset: "numeric" });

gen.next();    // generate unique ID
gen.count;     // how many generated
gen.has(id);   // check if already used
gen.reset();   // clear registry

Utilities

// How likely is a collision with 1M IDs at length 6?
collisionProbability(6, "numeric", 1_000_000);

// What length do I need for 1M IDs with 1-in-a-billion collision risk?
recommendedLength("alphanumeric", 1_000_000);

Common Use Cases

// E-commerce order number (10 digits)
generateNumber(10);

// Coupon code (8 alphanumeric)
generateAlphanumeric(8);

// Database primary key (URL-safe, 12 chars)
generateBase62(12);

// Sortable log/event ID
generateSortable(6);

// Batch of unique coupon codes
const coupons = createUniqueGenerator({ length: 8, charset: "alphanumeric" });
for (let i = 0; i < 1000; i++) {
  console.log(coupons.next());
}

Security

Uses Node.js crypto.randomBytes — cryptographically secure, not Math.random().

Rejection sampling ensures uniform distribution across all characters (no bias).

License

MIT