This release is 3 versions behind 0.2.1 — the latest version of @its-satyajit/id-generator. Jump to latest
@its-satyajit/id-generator@0.1.6Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
Built and signed on GitHub Actions
A lightweight TypeScript utility for generating various types of unique identifiers. This library provides three different ID generation methods, each optimized for specific use cases.
This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers




JSR Score
100%
Published
4 months ago (0.1.6)
import { RandomIdGenerator } from "./methods/randomGenerator.ts"; import { ShortUuidV7Generator } from "./methods/shortUuidV7Generator.ts"; import { TimeBasedGenerator } from "./methods/timeBasedGenerator.ts"; import { UuidV7Generator } from "./methods/uuidV7Generator.ts"; export class IdGenerator { /** * Generates a random ID (default 16 characters) * @param size Optional length of the ID * @returns Random ID string */ static random(size?: number): string { return new RandomIdGenerator().generate(size); } /** * Generates a full UUID v7 * @returns UUID v7 string */ static uuidV7(): string { return new UuidV7Generator().generate(); } /** * Generates a short UUID v7 (22 characters) * @returns Short UUID v7 string */ static shortUuidV7(): string { return new ShortUuidV7Generator().generate(); } /** * Generates a time-based ID * @returns Time-based ID string */ static timeId(): string { return new TimeBasedGenerator().generate(); } }