Skip to main content
Module

std/ulid/mod.ts>monotonicUlid

Deno standard library
Go to Latest
variable monotonicUlid
import { monotonicUlid } from "https://deno.land/std@0.210.0/ulid/mod.ts";

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

Examples

Example 1

import { monotonicUlid } from "https://deno.land/std@0.210.0/ulid/mod.ts";

// 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

type

ULID