Skip to content

@xtandard/lib/ulid

Prefixed ULID generation and helpers (peer ulid).

import { … } from "@xtandard/lib/ulid";
Name Summary
getDateFromUlid Read the creation time embedded in a prefixed or plain ULID, as a Date. Handy as a coarse “created at” for debugging and sorting; don’t use it in place of a stored timestamp.
getTimestampFromUlid Read the creation time embedded in a prefixed or plain ULID, in epoch milliseconds.
getUlidFromId Get the ULID part of a prefixed (usr_01jd…) or plain id, uppercased.
isValidUlid Whether a prefixed or plain id holds a well-formed 26-character ULID (Crockford base32, case-insensitive).
ulid Generates a ULID, optionally with a Stripe-style type prefix (usr_01jd…).