Skip to main content


The Deno Standard Library
Go to Latest
variable monotonicUlid
import { monotonicUlid } from "";

Generate a monotonically increasing ULID, optionally based on a given timestamp.


Example 1

import { monotonicUlid } from "";

// Strict ordering for the same timestamp, by incrementing the least-significant random bit by 1
monotonicUlid(150000); // 000XAL6S41ACTAV9WEVGEMMVR8
monotonicUlid(150000); // 000XAL6S41ACTAV9WEVGEMMVR9
monotonicUlid(150000); // 000XAL6S41ACTAV9WEVGEMMVRA
monotonicUlid(150000); // 000XAL6S41ACTAV9WEVGEMMVRB
monotonicUlid(150000); // 000XAL6S41ACTAV9WEVGEMMVRC

// Even if a lower timestamp is passed (or generated), it will preserve sort order
monotonicUlid(100000); // 000XAL6S41ACTAV9WEVGEMMVRD