-
Notifications
You must be signed in to change notification settings - Fork 1
/
mod.ts
41 lines (41 loc) · 1.23 KB
/
mod.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
* Utilities for generating and working with Universally Unique Lexicographically Sortable Identifiers (ULIDs).
*
* To generate a ULID use the {@linkcode ulid} function. This will generate a
* ULID based on the current time.
*
* ```ts no-assert
* import { ulid } from "@fajar/deno-ulid";
*
* ulid();
* ```
*
* {@linkcode ulid} does not guarantee that the ULIDs will be strictly
* increasing for the same current time. If you need to guarantee that the ULIDs
* will be strictly increasing, even for the same current time, use the
* {@linkcode monotonicUlid} function.
*
* ```ts no-assert
* import { monotonicUlid } from "@fajar/deno-ulid";
*
* monotonicUlid(); // 01HYFKHG5F8RHM2PM3D7NSTDAS
* monotonicUlid(); // 01HYFKHG5F8RHM2PM3D7NSTDAT
* ```
*
* Because each ULID encodes the time it was generated, you can extract the
* timestamp from a ULID using the {@linkcode decodeTime} function.
*
* ```ts
* import { decodeTime, ulid } from "@fajar/deno-ulid";
* import { assertEquals } from "@std/assert";
*
* const timestamp = 150_000;
* const ulidString = ulid(timestamp);
*
* assertEquals(decodeTime(ulidString), timestamp);
* ```
*
* @module
*/
export * from "./lib/index.ts";
export type * from "./types/index.d.ts";