← index

ULID

inherits Object

A 128-bit sortable identifier: a 48-bit millisecond timestamp plus 80 random bits, rendered as 26 characters of Crockford base32. String order equals creation order, so ULIDs make good keys where insertion order matters. Generate with ULID.generate, parse with ULID.parse:.

ULID.generate.s.length     "* -> 26
extended at core/16-serialize.qn:54

The canonical Crockford base32 form (ULID.parse: reads it back).

Class methods

generate

A new ULID stamped with the current time plus randomness.

ULID.generate.s.length     "* -> 26

native

parse:String

The ULID for a 26-character Crockford-base32 String; raises a ValueError otherwise.

ULID.parse:'01ARZ3NDEKTSV4RRFFQ69G5FAV'     "* -> 01ARZ3NDEKTSV4RRFFQ69G5FAV

native

Instance methods

<:ULID

Less-than against another ULID -- lexicographic on the canonical string, which is chronological order (the timestamp occupies the high bits). The one native comparison -- the others derive from it.

native

==:

Whether the argument is the same ULID (by value); a non-ULID is simply unequal, never an error.

native

asBytes

The 16 raw bytes, timestamp first (big-endian).

native

asData

core/16-serialize.qn:55

s

The canonical 26-character uppercase Crockford-base32 form.

native

timestampMillis

The embedded creation time, as Unix milliseconds.

(ULID.parse:'01ARZ3NDEKTSV4RRFFQ69G5FAV').timestampMillis     "* -> 1469922850259

native