You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+44-9
Original file line number
Diff line number
Diff line change
@@ -18,9 +18,13 @@ For the creation of [RFC4122](https://www.ietf.org/rfc/rfc4122.txt) UUIDs
18
18
-**Small** - Zero-dependency, small footprint, plays nice with "tree shaking" packagers
19
19
-**CLI** - Includes the [`uuid` command line](#command-line) utility
20
20
21
-
> **Note** Upgrading from `uuid@3`? Your code is probably okay, but check out [Upgrading From `uuid@3`](#upgrading-from-uuid3) for details.
21
+
<!-- prettier-ignore -->
22
+
> [!NOTE]
23
+
> Upgrading from `uuid@3`? Your code is probably okay, but check out [Upgrading From `uuid@3`](#upgrading-from-uuid3) for details.
22
24
23
-
> **Note** Only interested in creating a version 4 UUID? You might be able to use [`crypto.randomUUID()`](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID), eliminating the need to install this library.
25
+
<!-- prettier-ignore -->
26
+
> [!NOTE]
27
+
> Only interested in creating a version 4 UUID? You might be able to use [`crypto.randomUUID()`](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID), eliminating the need to install this library.
24
28
25
29
## Quickstart
26
30
@@ -53,6 +57,7 @@ For timestamp UUIDs, namespace UUIDs, and other options read on ...
53
57
||||
54
58
| --- | --- | --- |
55
59
|[`uuid.NIL`](#uuidnil)| The nil UUID string (all zeros) | New in `uuid@8.3`|
60
+
|[`uuid.MAX`](#uuidmax)| The max UUID string (all ones) | New in `uuid@9.1`|
56
61
|[`uuid.parse()`](#uuidparsestr)| Convert UUID string to array of bytes | New in `uuid@8.3`|
57
62
|[`uuid.stringify()`](#uuidstringifyarr-offset)| Convert array of bytes to UUID string | New in `uuid@8.3`|
58
63
|[`uuid.v1()`](#uuidv1options-buffer-offset)| Create a version 1 (timestamp) UUID ||
@@ -77,6 +82,18 @@ import { NIL as NIL_UUID } from 'uuid';
@@ -87,7 +104,9 @@ Convert UUID string to array of bytes
87
104
|_returns_|`Uint8Array[16]`|
88
105
|_throws_|`TypeError` if `str` is not a valid UUID |
89
106
90
-
Note: Ordering of values in the byte arrays used by `parse()` and `stringify()` follows the left ↠ right order of hex-pairs in UUID strings. As shown in the example below.
107
+
<!-- prettier-ignore -->
108
+
> [!NOTE]
109
+
> Ordering of values in the byte arrays used by `parse()` and `stringify()` follows the left ↠ right order of hex-pairs in UUID strings. As shown in the example below.
91
110
92
111
Example:
93
112
@@ -118,7 +137,9 @@ Convert array of bytes to UUID string
118
137
|_returns_|`String`|
119
138
|_throws_|`TypeError` if a valid UUID string cannot be generated |
120
139
121
-
Note: Ordering of values in the byte arrays used by `parse()` and `stringify()` follows the left ↠ right order of hex-pairs in UUID strings. As shown in the example below.
140
+
<!-- prettier-ignore -->
141
+
> [!NOTE]
142
+
> Ordering of values in the byte arrays used by `parse()` and `stringify()` follows the left ↠ right order of hex-pairs in UUID strings. As shown in the example below.
122
143
123
144
Example:
124
145
@@ -150,9 +171,13 @@ Create an RFC version 1 (timestamp) UUID
150
171
|_returns_| UUID `String` if no `buffer` is specified, otherwise returns `buffer`|
151
172
|_throws_|`Error` if more than 10M UUIDs/sec are requested |
152
173
153
-
Note: The default [node id](https://tools.ietf.org/html/rfc4122#section-4.1.6) (the last 12 digits in the UUID) is generated once, randomly, on process startup, and then remains unchanged for the duration of the process.
174
+
<!-- prettier-ignore -->
175
+
> [!NOTE]
176
+
> The default [node id](https://tools.ietf.org/html/rfc4122#section-4.1.6) (the last 12 digits in the UUID) is generated once, randomly, on process startup, and then remains unchanged for the duration of the process.
154
177
155
-
Note: `options.random` and `options.rng` are only meaningful on the very first call to `v1()`, where they may be passed to initialize the internal `node` and `clockseq` fields.
178
+
<!-- prettier-ignore -->
179
+
> [!NOTE]
180
+
> `options.random` and `options.rng` are only meaningful on the very first call to `v1()`, where they may be passed to initialize the internal `node` and `clockseq` fields.
156
181
157
182
Example:
158
183
@@ -182,7 +207,9 @@ Create an RFC version 3 (namespace w/ MD5) UUID
182
207
183
208
API is identical to `v5()`, but uses "v3" instead.
184
209
185
-
⚠️ Note: Per the RFC, "_If backward compatibility is not an issue, SHA-1 [Version 5] is preferred_."
210
+
<!-- prettier-ignore -->
211
+
> [!IMPORTANT]
212
+
> Per the RFC, "_If backward compatibility is not an issue, SHA-1 [Version 5] is preferred_."
186
213
187
214
### uuid.v4([options[, buffer[, offset]]])
188
215
@@ -230,7 +257,9 @@ Create an RFC version 5 (namespace w/ SHA-1) UUID
230
257
|[`offset` = 0]|`Number` Index to start writing UUID bytes in `buffer`|
231
258
|_returns_| UUID `String` if no `buffer` is specified, otherwise returns `buffer`|
232
259
233
-
Note: The RFC `DNS` and `URL` namespaces are available as `v5.DNS` and `v5.URL`.
260
+
<!-- prettier-ignore -->
261
+
> [!NOTE]
262
+
> The RFC `DNS` and `URL` namespaces are available as `v5.DNS` and `v5.URL`.
Copy file name to clipboardexpand all lines: README_js.md
+44-9
Original file line number
Diff line number
Diff line change
@@ -32,9 +32,13 @@ For the creation of [RFC4122](https://www.ietf.org/rfc/rfc4122.txt) UUIDs
32
32
-**Small** - Zero-dependency, small footprint, plays nice with "tree shaking" packagers
33
33
-**CLI** - Includes the [`uuid` command line](#command-line) utility
34
34
35
-
> **Note** Upgrading from `uuid@3`? Your code is probably okay, but check out [Upgrading From `uuid@3`](#upgrading-from-uuid3) for details.
35
+
<!-- prettier-ignore -->
36
+
> [!NOTE]
37
+
> Upgrading from `uuid@3`? Your code is probably okay, but check out [Upgrading From `uuid@3`](#upgrading-from-uuid3) for details.
36
38
37
-
> **Note** Only interested in creating a version 4 UUID? You might be able to use [`crypto.randomUUID()`](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID), eliminating the need to install this library.
39
+
<!-- prettier-ignore -->
40
+
> [!NOTE]
41
+
> Only interested in creating a version 4 UUID? You might be able to use [`crypto.randomUUID()`](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID), eliminating the need to install this library.
38
42
39
43
## Quickstart
40
44
@@ -67,6 +71,7 @@ For timestamp UUIDs, namespace UUIDs, and other options read on ...
67
71
||||
68
72
| --- | --- | --- |
69
73
|[`uuid.NIL`](#uuidnil)| The nil UUID string (all zeros) | New in `uuid@8.3`|
74
+
|[`uuid.MAX`](#uuidmax)| The max UUID string (all ones) | New in `uuid@9.1`|
70
75
|[`uuid.parse()`](#uuidparsestr)| Convert UUID string to array of bytes | New in `uuid@8.3`|
71
76
|[`uuid.stringify()`](#uuidstringifyarr-offset)| Convert array of bytes to UUID string | New in `uuid@8.3`|
72
77
|[`uuid.v1()`](#uuidv1options-buffer-offset)| Create a version 1 (timestamp) UUID ||
@@ -91,6 +96,18 @@ import { NIL as NIL_UUID } from 'uuid';
91
96
NIL_UUID; // RESULT
92
97
```
93
98
99
+
### uuid.MAX
100
+
101
+
The max UUID string (all ones).
102
+
103
+
Example:
104
+
105
+
```javascript --run
106
+
import { MAXasMAX_UUID } from'uuid';
107
+
108
+
MAX_UUID; // RESULT
109
+
```
110
+
94
111
### uuid.parse(str)
95
112
96
113
Convert UUID string to array of bytes
@@ -101,7 +118,9 @@ Convert UUID string to array of bytes
101
118
|_returns_|`Uint8Array[16]`|
102
119
|_throws_|`TypeError` if `str` is not a valid UUID |
103
120
104
-
Note: Ordering of values in the byte arrays used by `parse()` and `stringify()` follows the left ↠ right order of hex-pairs in UUID strings. As shown in the example below.
121
+
<!-- prettier-ignore -->
122
+
> [!NOTE]
123
+
> Ordering of values in the byte arrays used by `parse()` and `stringify()` follows the left ↠ right order of hex-pairs in UUID strings. As shown in the example below.
105
124
106
125
Example:
107
126
@@ -126,7 +145,9 @@ Convert array of bytes to UUID string
126
145
|_returns_|`String`|
127
146
|_throws_|`TypeError` if a valid UUID string cannot be generated |
128
147
129
-
Note: Ordering of values in the byte arrays used by `parse()` and `stringify()` follows the left ↠ right order of hex-pairs in UUID strings. As shown in the example below.
148
+
<!-- prettier-ignore -->
149
+
> [!NOTE]
150
+
> Ordering of values in the byte arrays used by `parse()` and `stringify()` follows the left ↠ right order of hex-pairs in UUID strings. As shown in the example below.
130
151
131
152
Example:
132
153
@@ -158,9 +179,13 @@ Create an RFC version 1 (timestamp) UUID
158
179
|_returns_| UUID `String` if no `buffer` is specified, otherwise returns `buffer`|
159
180
|_throws_|`Error` if more than 10M UUIDs/sec are requested |
160
181
161
-
Note: The default [node id](https://tools.ietf.org/html/rfc4122#section-4.1.6) (the last 12 digits in the UUID) is generated once, randomly, on process startup, and then remains unchanged for the duration of the process.
182
+
<!-- prettier-ignore -->
183
+
> [!NOTE]
184
+
> The default [node id](https://tools.ietf.org/html/rfc4122#section-4.1.6) (the last 12 digits in the UUID) is generated once, randomly, on process startup, and then remains unchanged for the duration of the process.
162
185
163
-
Note: `options.random` and `options.rng` are only meaningful on the very first call to `v1()`, where they may be passed to initialize the internal `node` and `clockseq` fields.
186
+
<!-- prettier-ignore -->
187
+
> [!NOTE]
188
+
> `options.random` and `options.rng` are only meaningful on the very first call to `v1()`, where they may be passed to initialize the internal `node` and `clockseq` fields.
164
189
165
190
Example:
166
191
@@ -190,7 +215,9 @@ Create an RFC version 3 (namespace w/ MD5) UUID
190
215
191
216
API is identical to `v5()`, but uses "v3" instead.
192
217
193
-
⚠️ Note: Per the RFC, "_If backward compatibility is not an issue, SHA-1 [Version 5] is preferred_."
218
+
<!-- prettier-ignore -->
219
+
> [!IMPORTANT]
220
+
> Per the RFC, "_If backward compatibility is not an issue, SHA-1 [Version 5] is preferred_."
194
221
195
222
### uuid.v4([options[, buffer[, offset]]])
196
223
@@ -238,7 +265,9 @@ Create an RFC version 5 (namespace w/ SHA-1) UUID
238
265
|[`offset` = 0]|`Number` Index to start writing UUID bytes in `buffer`|
239
266
|_returns_| UUID `String` if no `buffer` is specified, otherwise returns `buffer`|
240
267
241
-
Note: The RFC `DNS` and `URL` namespaces are available as `v5.DNS` and `v5.URL`.
268
+
<!-- prettier-ignore -->
269
+
> [!NOTE]
270
+
> The RFC `DNS` and `URL` namespaces are available as `v5.DNS` and `v5.URL`.
242
271
243
272
Example with custom namespace:
244
273
@@ -337,6 +366,10 @@ uuidVersion('45637ec4-c85f-11ea-87d0-0242ac130003'); // RESULT
337
366
uuidVersion('6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b'); // RESULT
338
367
```
339
368
369
+
<!-- prettier-ignore -->
370
+
> [!NOTE]
371
+
> This method returns `0` for the `NIL` UUID, and `15` for the `MAX` UUID.
372
+
340
373
## Command Line
341
374
342
375
UUIDs can be generated from the command line using `uuid`.
0 commit comments