Generates ULIDs (Universally Unique Lexicographically Sortable Identifiers) using timestamp and random components, ensuring monotonic ordering within the same millisecond.
// Source: https://github.com/wexare-ai/openbrowserclaw | License: MIT | Copyright 2026 Sacha Arbonel
// Provided via justclaw.it.com; keep this notice with the code.
// ---------------------------------------------------------------------------
// OpenBrowserClaw — ULID generator (no dependencies)
// ---------------------------------------------------------------------------
const ENCODING = '0123456789ABCDEFGHJKMNPQRSTVWXYZ';
const ENCODING_LEN = ENCODING.length;
const TIME_LEN = 10;
const RANDOM_LEN = 16;
let lastTime = 0;
let lastRandom: number[] = [];
/**
* Generate a ULID (Universally Unique Lexicographically Sortable Identifier).
* Monotonically increasing within the same millisecond.
*/
export function ulid(): string {
const now = Date.now();
if (now === lastTime) {
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key