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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@uscreen.de/id-generator

v1.0.0

Published

Generate unique, sortable IDs with optional prefixes using ULID

Downloads

28

Readme

@uscreen.de/id-generator

CI npm version Known Vulnerabilities codecov License: MIT

Generate unique, sortable IDs with optional prefixes using ULID.

Features

  • Unique: Uses ULID (Universally Unique Lexicographically Sortable Identifier)
  • Sortable: IDs are lexicographically sortable by timestamp
  • Prefixable: Add custom prefixes to categorize your IDs
  • Monotonic: Ensures proper ordering even within the same millisecond
  • Lowercase: All IDs are returned in lowercase for consistency

Installation

pnpm add @uscreen.de/id-generator

Or with npm:

npm install @uscreen.de/id-generator

Usage

import { generateId, id, newId } from '@uscreen.de/id-generator'

// Generate a basic ID
const basicId = id()
// → '01hmqr8x3jk9v7n8q2m1c4d5f6'

// Generate an ID with a prefix
const userId = id('user')
// → 'user_01hmqr8x3jk9v7n8q2m1c4d5f6'

const orderId = id('order')
// → 'order_01hmqr8x3jk9v7n8q2m1c4d5f7'

// Use aliases (all do the same thing)
const id1 = generateId('product')
const id2 = newId('category')

API

id(prefix?: string): string

Generates a unique, sortable ID.

Parameters:

  • prefix (optional): String prefix to prepend to the ID, separated by underscore

Returns:

  • A unique ID string, optionally prefixed

Aliases

  • generateId(prefix?: string): string - Alias for id()
  • newId(prefix?: string): string - Alias for id()

Examples

import { id } from '@uscreen.de/id-generator'

// Database records
const userId = id('user') // 'user_01hmqr8x3jk9v7n8q2m1c4d5f6'
const postId = id('post') // 'post_01hmqr8x3jk9v7n8q2m1c4d5f7'
const commentId = id('comment') // 'comment_01hmqr8x3jk9v7n8q2m1c4d5f8'

// File names
const fileName = id('upload') // 'upload_01hmqr8x3jk9v7n8q2m1c4d5f9'

// Session IDs
const sessionId = id('session') // 'session_01hmqr8x3jk9v7n8q2m1c4d5fa'

// No prefix
const simpleId = id() // '01hmqr8x3jk9v7n8q2m1c4d5fb'

Why ULID?

ULID combines the best of UUIDs and timestamp-based IDs:

  • 128-bit compatibility with UUID
  • Lexicographically sortable by timestamp
  • Canonically encoded as 26 character string (vs 36 for UUID)
  • URL safe base32 encoding
  • Case insensitive and monotonic within same millisecond

Testing

This project maintains 100% test coverage. Run tests with:

pnpm test          # Run all tests
pnpm test:cov      # Run with coverage report
pnpm test:ci       # Run in CI mode

Requirements

  • Node.js 18 or higher
  • ES modules support

License

MIT

Author

Marcus Spiegel [email protected] - published, supported and sponsored by u|screen