A library for generating ULID and utility functions.
opaque type for ULID.
ULID is composed of a Timestamp and a Randomenss part with the following format.
01AN4Z07BY 79KA1307SR9X4MV3
|----------| |----------------|
Timestamp Randomness
48bits 80bits
ulidGenerator : Time.Posix -> Random.Generator Ulid
Random generator for a single ULID at specified time.
multipleUlidGenerator : Basics.Int -> Time.Posix -> Random.Generator (List Ulid)
Random generator for multilpe ULIDs at the same milisecond. The generated ULIDs have no specific sort order. We can not see use cases for generating ULIDs sortable within the same milisecond on client side apps. So Monotonicity is not supported in this packages.
toString : Ulid -> String
Extract the string representation.
fromString : String -> Maybe Ulid
Try to parse a string representation as an ULID, ie. 26 character length with valid characters of
0123456789ABCDEFGHJKMNPQRSTVWXYZ
. Detect overflowing if the ULID is larger than 7ZZZZZZZZZZZZZZZZZZZZZZZZZ
.
toTimestamp : Ulid -> Time.Posix
Extract the Timestamp part only.
encode : Ulid -> Json.Encode.Value
Encode a ULID as json
decode : Json.Decode.Decoder Ulid
Decode a ULID from a JSON value
toUuidString : Ulid -> String
Produce a canonical 8-4-4-4-12 UUID string form.
The variant and version indicators of converted UUID are meaningless,
so the Uuid.fromString
in dandy32/elm-uuid will fail.
fromUuidString : String -> Maybe Ulid
Try to parse an UUID string, though the timestamp is meaningless.
If it overflows Nothing
value will be returned.