Generate, check, and parse unique IDs with tagged prefixes
src | ||
.gitignore | ||
bun.lock | ||
LICENSE | ||
package.json | ||
README.md | ||
tsconfig.json |
Tagged Identifiers
Generate, check, and parse unique identifiers with tagged prefixes. Identifiers are generated using nanoid.
Usage
import { taggedId, isTaggedId, parseTaggedId } from "@endeavorance/tagged-id";
const id = taggedId("demo");
console.log(id); // demo_28hD92jMsIw92KqM
isTaggedId("demo", id); // true
parseTaggedId("demo", id); // demo_28hD92jMsIw92KqM
isTaggedId("other", id); // false
parseTaggedId("other", id) // throws an Error
Set up
Configure your environment to point to git.astral.camp
for @endeavorance
packages, then install and use as normal.
npm
For NPM, update your .npmrc for the project or globally:
@endeavorance:registry=https://git.astral.camp/api/packages/endeavorance/npm/
Then install with npm i @endeavorance/tagged-id
bun
For Bun, use bunfig.toml
[install.scopes]
endeavorance = "https://git.astral.camp/api/packages/endeavorance/npm/"
Then install with bun add @endeavorance/tagged-id