Skip to content
Quickstart

Quickstart

Small, opaque identity and candidate-word primitives for Fungi packages

This illustrative example creates one caller-owned ID family, generates an ID, and checks a decoded string without changing its spelling:

quickstart.ts
import { defineIdFamily } from "@fungi.computer/cairn/id";
const jobIds = defineIdFamily({
family: "jobs",
version: 1,
kinds: { job: { prefix: "job" } },
});
const jobId = jobIds.job.generate();
const result = jobIds.job.parse(jobId);
if (!result.ok) throw new Error(`Invalid job ID: ${result.error.reason}`);

The result is a canonical job_ identifier. The runnable ID tests exercise family-scoped generation and parsing in src/id.test.ts.