1 |
|
2 | export {};
|
3 |
|
4 |
|
5 | type OutputBuffer = ArrayLike<number>;
|
6 | type InputBuffer = ArrayLike<number>;
|
7 |
|
8 | interface RandomOptions {
|
9 |
|
10 | random?: InputBuffer | undefined;
|
11 | }
|
12 | interface RngOptions {
|
13 |
|
14 | rng?: (() => InputBuffer) | undefined;
|
15 | }
|
16 |
|
17 | interface V1BaseOptions {
|
18 | /** RFC "node" field as an `Array[6]` of byte values (per 4.1.6) */
|
19 | node?: InputBuffer | undefined;
|
20 | /** RFC "clock sequence" as a `Number` between 0 - 0x3fff */
|
21 | clockseq?: number | undefined;
|
22 | /** RFC "timestamp" field (`Number` of milliseconds, unix epoch) */
|
23 | msecs?: number | Date | undefined;
|
24 | /** RFC "timestamp" field (`Number` of nanoseconds to add to msecs, should be 0-10,000) */
|
25 | nsecs?: number | undefined;
|
26 | }
|
27 | interface V1RandomOptions extends V1BaseOptions, RandomOptions {}
|
28 | interface V1RngOptions extends V1BaseOptions, RngOptions {}
|
29 |
|
30 | export type V1Options = V1RandomOptions | V1RngOptions;
|
31 | export type V4Options = RandomOptions | RngOptions;
|
32 | export type V6Options = V1Options;
|
33 |
|
34 | interface V7BaseOptions {
|
35 | msecs?: number | Date | undefined;
|
36 | seq?: number;
|
37 | }
|
38 | export type V7Options = (RandomOptions | RngOptions) & V7BaseOptions;
|
39 |
|
40 | type VToV = ((uuid: string) => string) & ((uuid: OutputBuffer) => Uint8Array);
|
41 |
|
42 | type v1String = (options?: V1Options) => string;
|
43 | type v1Buffer = <T extends OutputBuffer>(options: V1Options | null | undefined, buffer: T, offset?: number) => T;
|
44 | type v1 = v1Buffer & v1String;
|
45 |
|
46 | type v1ToV6 = VToV;
|
47 |
|
48 | type v4String = (options?: V4Options) => string;
|
49 | type v4Buffer = <T extends OutputBuffer>(options: V4Options | null | undefined, buffer: T, offset?: number) => T;
|
50 | type v4 = v4Buffer & v4String;
|
51 |
|
52 | type v3String = (name: string | InputBuffer, namespace: string | InputBuffer) => string;
|
53 | type v3Buffer = <T extends OutputBuffer>(
|
54 | name: string | InputBuffer,
|
55 | namespace: string | InputBuffer,
|
56 | buffer: T,
|
57 | offset?: number,
|
58 | ) => T;
|
59 | interface v3Static {
|
60 |
|
61 | DNS: string;
|
62 |
|
63 | URL: string;
|
64 | }
|
65 | type v3 = v3Buffer & v3String & v3Static;
|
66 |
|
67 | type v5String = (name: string | InputBuffer, namespace: string | InputBuffer) => string;
|
68 | type v5Buffer = <T extends OutputBuffer>(
|
69 | name: string | InputBuffer,
|
70 | namespace: string | InputBuffer,
|
71 | buffer: T,
|
72 | offset?: number,
|
73 | ) => T;
|
74 | interface v5Static {
|
75 |
|
76 | DNS: string;
|
77 |
|
78 | URL: string;
|
79 | }
|
80 | type v5 = v5Buffer & v5String & v5Static;
|
81 |
|
82 | type v6String = (options?: V6Options) => string;
|
83 | type v6Buffer = <T extends OutputBuffer>(options: V6Options | null | undefined, buffer: T, offset?: number) => T;
|
84 | type v6 = v6Buffer & v6String;
|
85 |
|
86 | type v6ToV1 = VToV;
|
87 |
|
88 | type v7String = (options?: V7Options) => string;
|
89 | type v7Buffer = <T extends OutputBuffer>(options: V7Options | null | undefined, buffer: T, offset?: number) => T;
|
90 | type v7 = v7Buffer & v7String;
|
91 |
|
92 | type NIL = string;
|
93 | type MAX = string;
|
94 |
|
95 | type parse = (uuid: string) => Uint8Array;
|
96 | type stringify = (buffer: InputBuffer, offset?: number) => string;
|
97 | type validate = (uuid: string) => boolean;
|
98 | type version = (uuid: string) => number;
|
99 |
|
100 | export const NIL: NIL;
|
101 | export const MAX: MAX;
|
102 | export const parse: parse;
|
103 | export const stringify: stringify;
|
104 | export const v1: v1;
|
105 | export const v1ToV6: v1ToV6;
|
106 | export const v3: v3;
|
107 | export const v4: v4;
|
108 | export const v5: v5;
|
109 | export const v6: v6;
|
110 | export const v6ToV1: v6ToV1;
|
111 | export const v7: v7;
|
112 | export const validate: validate;
|
113 | export const version: version;
|