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

@seasb/type-id

v0.1.1

Published

TypeScript-first toolkit for type-prefixed human-readable IDs that map to your system entity types (e.g. t_a3f9bc)

Readme

Type-id

A tiny TypeScript utility for creating and managing type-prefixed, human-readable IDs (e.g. t_01Jz4K8mA3f9bc, tm_x8k2f1).

Schema-first: define your entity types and prefixes once via configure(), get back a fully typed toolkit.

Functional: Avoids using classes and OO mechanics. Does hold state in the config.

Install

npm install type-id

Quick start

src/ids.ts — define your entity types once:

import { configure } from "type-id";

export const {
  newId,
  toType,
  toPrefix,
  toUniqPart,
  isTypeId,
  isTypeOf,
  extractIds,
} = configure({
  task: "t",
  user: ["tm", 6], // [prefix, idLength] — shorter IDs for users
  project: "p",
});

Anywhere else in your project:

import { newId, toType, isTypeOf, extractIds } from "./ids";

// Generate IDs
const taskId = newId("task"); // "t_01Jz4K8mA3f9bc"
const userId = newId("user"); // "tm_x8k2f1"
const projId = newId("project"); // "p_01Jz4K8m9bc1a3"

// With your own suffix
newId("task", "my-custom-suffix"); // "t_my-custom-suffix"

// Inspect IDs
toType("t_01Jz4K8mA3f9bc"); // "task"
toType("unknown_foo"); // undefined

// Validate
isTypeId("t_01Jz4K8mA3f9bc"); // true
isTypeId("random string"); // false
isTypeOf("t_01Jz4K8mA3f9bc", "task"); // true
isTypeOf("p_01Jz4K8m9bc1a3", "task"); // false

// Extract IDs from text
extractIds("See t_01Jz4K8mA3f9bc and p_01Jz4K8m9bc1a3 for context.");
// ["t_01Jz4K8mA3f9bc", "p_01Jz4K8m9bc1a3"]

API

configure(entityConfigs, config?)

Main entry point. Returns a fully typed Instance<T>.

entityConfigs: Record<T, string | [string, number]>

Maps each entity type to its prefix, or a [prefix, idLength] tuple for per-type length control.

configure({
  task: "t", // uses defaultLength
  user: ["tm", 6], // always 6 chars
  project: "p",
});

config (optional):

| Option | Default | Description | | --------------- | ---------------------------------- | --------------------------------------------------------------------------------- | | defaultLength | 22 | Suffix character count (default is UUID-level entropy) | | generateId | time-ordered base62 (UUIDv7-style) | Custom (length: number) => string — inject nanoid or crypto.randomUUID here |

import { nanoid } from "nanoid";

const ids = configure({ task: "t" }, { generateId: (len) => nanoid(len) });

Methods on Instance<T>

| Method | Description | | ---------------------- | -------------------------------------------------------------- | | newId(type, suffix?) | Generate a new ID; optionally provide your own suffix | | toType(id) | Extract entity type from ID string (undefined if unknown) | | toPrefix(type) | Get the prefix string for a type | | isTypeId(id) | Returns true if string matches any registered prefix pattern | | isTypeOf(id, type) | Returns true if the ID belongs to the given type | | toUniqPart(id) | Extract the unique suffix after the prefix | | extractIds(text) | Find all valid IDs embedded in a longer text string | | HUMAN_ID_REGEX | Compiled global RegExp for matching IDs inline in text | | HUMAN_ID_REGEX_EXACT | Compiled global RegExp for exact full-string matching |

License

MIT