ID Generation Functions¶
Functions for generating and inspecting identifiers.
Summary¶
| Function | Signature | Description |
|---|---|---|
nanoid |
number? -> string |
Generate nanoid with an optional whole-number size from 0 through 1024 inclusive (integral floats accepted). Defaults to 21 characters; size 0 returns an empty string. |
ulid |
-> string |
Generate ULID |
ulid_timestamp |
string -> number |
Extract timestamp from ULID |
Functions¶
nanoid¶
Generate nanoid with an optional whole-number size from 0 through 1024 inclusive (integral floats accepted). Defaults to 21 characters; size 0 returns an empty string.
Signature: number? -> string
Examples:
# Default 21 chars
nanoid() -> \"V1StGXR8_Z5jdHi6B-myT\"
# Custom length
nanoid(`10`) -> \"IRFa-VaY2b\"
ulid¶
Generate ULID
Signature: -> string
Examples:
ulid_timestamp¶
Extract timestamp from ULID
Signature: string -> number
Examples: