Cairn
Typed, opaque IDs and short-lived keys for TypeScript services, so you never hand-roll an ID format or its parser again.
Fastest path
Install
Add it to your project with npm, pnpm, Yarn or Bun.
TERMINAL npm install @fungi.computer/cairnMint and check an ID
Declare an ID family once, then generate IDs and parse untrusted strings with the same codec.
home.ts import { defineIdFamily } from "@fungi.computer/cairn/id";import { words } from "@fungi.computer/cairn/words";const ids = defineIdFamily({family: "jobs",version: 1,kinds: { job: { prefix: "job" } },});const id = ids.job.generate();console.log(id); // job_ and 21 base36 charactersconsole.log(ids.job.parse(id).ok); // trueconsole.log(ids.job.parse("job_TOO-SHORT").ok); // falseconsole.log(words()); // a candidate name such as "quiet-fern"