uuid 13.0.0 → 14.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -32,32 +32,32 @@ npm install uuid
32
32
  **2. Create a UUID**
33
33
 
34
34
  ```javascript
35
- import { v4 as uuidv4 } from 'uuid';
35
+ import { v4 as uuidv4 } from "uuid";
36
36
 
37
- uuidv4(); // ⇨ '9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d'
37
+ uuidv4(); // ⇨ 'ab16e731-6cee-424d-81a0-5929e9bdb0cc'
38
38
  ```
39
39
 
40
40
  For timestamp UUIDs, namespace UUIDs, and other options read on ...
41
41
 
42
42
  ## API Summary
43
43
 
44
- | | | |
45
- | --- | --- | --- |
46
- | [`uuid.NIL`](#uuidnil) | The nil UUID string (all zeros) | New in `uuid@8.3` |
47
- | [`uuid.MAX`](#uuidmax) | The max UUID string (all ones) | New in `uuid@9.1` |
48
- | [`uuid.parse()`](#uuidparsestr) | Convert UUID string to array of bytes | New in `uuid@8.3` |
49
- | [`uuid.stringify()`](#uuidstringifyarr-offset) | Convert array of bytes to UUID string | New in `uuid@8.3` |
50
- | [`uuid.v1()`](#uuidv1options-buffer-offset) | Create a version 1 (timestamp) UUID | |
51
- | [`uuid.v1ToV6()`](#uuidv1tov6uuid) | Create a version 6 UUID from a version 1 UUID | New in `uuid@10` |
52
- | [`uuid.v3()`](#uuidv3name-namespace-buffer-offset) | Create a version 3 (namespace w/ MD5) UUID | |
53
- | [`uuid.v4()`](#uuidv4options-buffer-offset) | Create a version 4 (random) UUID | |
54
- | [`uuid.v5()`](#uuidv5name-namespace-buffer-offset) | Create a version 5 (namespace w/ SHA-1) UUID | |
55
- | [`uuid.v6()`](#uuidv6options-buffer-offset) | Create a version 6 (timestamp, reordered) UUID | New in `uuid@10` |
56
- | [`uuid.v6ToV1()`](#uuidv6tov1uuid) | Create a version 1 UUID from a version 6 UUID | New in `uuid@10` |
57
- | [`uuid.v7()`](#uuidv7options-buffer-offset) | Create a version 7 (Unix Epoch time-based) UUID | New in `uuid@10` |
58
- | ~~[`uuid.v8()`](#uuidv8)~~ | "Intentionally left blank" | |
59
- | [`uuid.validate()`](#uuidvalidatestr) | Test a string to see if it is a valid UUID | New in `uuid@8.3` |
60
- | [`uuid.version()`](#uuidversionstr) | Detect RFC version of a UUID | New in `uuid@8.3` |
44
+ | | | |
45
+ | -------------------------------------------------- | ----------------------------------------------- | ----------------- |
46
+ | [`uuid.NIL`](#uuidnil) | The nil UUID string (all zeros) | New in `uuid@8.3` |
47
+ | [`uuid.MAX`](#uuidmax) | The max UUID string (all ones) | New in `uuid@9.1` |
48
+ | [`uuid.parse()`](#uuidparsestr) | Convert UUID string to array of bytes | New in `uuid@8.3` |
49
+ | [`uuid.stringify()`](#uuidstringifyarr-offset) | Convert array of bytes to UUID string | New in `uuid@8.3` |
50
+ | [`uuid.v1()`](#uuidv1options-buffer-offset) | Create a version 1 (timestamp) UUID | |
51
+ | [`uuid.v1ToV6()`](#uuidv1tov6uuid) | Create a version 6 UUID from a version 1 UUID | New in `uuid@10` |
52
+ | [`uuid.v3()`](#uuidv3name-namespace-buffer-offset) | Create a version 3 (namespace w/ MD5) UUID | |
53
+ | [`uuid.v4()`](#uuidv4options-buffer-offset) | Create a version 4 (random) UUID | |
54
+ | [`uuid.v5()`](#uuidv5name-namespace-buffer-offset) | Create a version 5 (namespace w/ SHA-1) UUID | |
55
+ | [`uuid.v6()`](#uuidv6options-buffer-offset) | Create a version 6 (timestamp, reordered) UUID | New in `uuid@10` |
56
+ | [`uuid.v6ToV1()`](#uuidv6tov1uuid) | Create a version 1 UUID from a version 6 UUID | New in `uuid@10` |
57
+ | [`uuid.v7()`](#uuidv7options-buffer-offset) | Create a version 7 (Unix Epoch time-based) UUID | New in `uuid@10` |
58
+ | ~~[`uuid.v8()`](#uuidv8)~~ | "Intentionally left blank" | |
59
+ | [`uuid.validate()`](#uuidvalidatestr) | Test a string to see if it is a valid UUID | New in `uuid@8.3` |
60
+ | [`uuid.version()`](#uuidversionstr) | Detect RFC version of a UUID | New in `uuid@8.3` |
61
61
 
62
62
  ## API
63
63
 
@@ -68,7 +68,7 @@ The nil UUID string (all zeros).
68
68
  Example:
69
69
 
70
70
  ```javascript
71
- import { NIL as NIL_UUID } from 'uuid';
71
+ import { NIL as NIL_UUID } from "uuid";
72
72
 
73
73
  NIL_UUID; // ⇨ '00000000-0000-0000-0000-000000000000'
74
74
  ```
@@ -80,7 +80,7 @@ The max UUID string (all ones).
80
80
  Example:
81
81
 
82
82
  ```javascript
83
- import { MAX as MAX_UUID } from 'uuid';
83
+ import { MAX as MAX_UUID } from "uuid";
84
84
 
85
85
  MAX_UUID; // ⇨ 'ffffffff-ffff-ffff-ffff-ffffffffffff'
86
86
  ```
@@ -102,10 +102,10 @@ Convert UUID string to array of bytes
102
102
  Example:
103
103
 
104
104
  ```javascript
105
- import { parse as uuidParse } from 'uuid';
105
+ import { parse as uuidParse } from "uuid";
106
106
 
107
107
  // Parse a UUID
108
- uuidParse('6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b'); // ⇨
108
+ uuidParse("6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b"); // ⇨
109
109
  // Uint8Array(16) [
110
110
  // 110, 192, 189, 127, 17,
111
111
  // 192, 67, 218, 151, 94,
@@ -132,7 +132,7 @@ Convert array of bytes to UUID string
132
132
  Example:
133
133
 
134
134
  ```javascript
135
- import { stringify as uuidStringify } from 'uuid';
135
+ import { stringify as uuidStringify } from "uuid";
136
136
 
137
137
  const uuidBytes = Uint8Array.of(
138
138
  0x6e,
@@ -150,7 +150,7 @@ const uuidBytes = Uint8Array.of(
150
150
  0xd9,
151
151
  0xeb,
152
152
  0xae,
153
- 0x0b
153
+ 0x0b,
154
154
  );
155
155
 
156
156
  uuidStringify(uuidBytes); // ⇨ '6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b'
@@ -160,45 +160,37 @@ uuidStringify(uuidBytes); // ⇨ '6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b'
160
160
 
161
161
  Create an RFC version 1 (timestamp) UUID
162
162
 
163
- | | |
164
- | --- | --- |
165
- | [`options`] | `Object` with one or more of the following properties: |
166
- | [`options.node = (random)` ] | RFC "node" field as an `Array[6]` of byte values (per 4.1.6) |
167
- | [`options.clockseq = (random)`] | RFC "clock sequence" as a `Number` between 0 - 0x3fff |
168
- | [`options.msecs = (current time)`] | RFC "timestamp" field (`Number` of milliseconds, unix epoch) |
169
- | [`options.nsecs = 0`] | RFC "timestamp" field (`Number` of nanoseconds to add to `msecs`, should be 0-10,000) |
170
- | [`options.random = (random)`] | `Array` of 16 random bytes (0-255) used to generate other fields, above |
171
- | [`options.rng`] | Alternative to `options.random`, a `Function` that returns an `Array` of 16 random bytes (0-255) |
172
- | [`buffer`] | `Uint8Array` or `Uint8Array` subtype (e.g. Node.js `Buffer`). If provided, binary UUID is written into the array, starting at `offset` |
173
- | [`offset` = 0] | `Number` Index to start writing UUID bytes in `buffer` |
174
- | _returns_ | UUID `String` if no `buffer` is specified, otherwise returns `buffer` |
175
- | _throws_ | `Error` if more than 10M UUIDs/sec are requested |
176
-
177
- <!-- prettier-ignore -->
178
- > [!NOTE]
179
- > The default [node id](https://datatracker.ietf.org/doc/html/rfc9562#section-5.1) (the last 12 digits in the UUID) is generated once, randomly, on process startup, and then remains unchanged for the duration of the process.
180
-
181
- <!-- prettier-ignore -->
182
- > [!NOTE]
183
- > `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.
163
+ | | |
164
+ | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
165
+ | [`options`] | `Object` with one or more of the following properties: |
166
+ | [`options.node = (random)` ] | RFC "node" field as an `Array[6]` of byte values (per 4.1.6) |
167
+ | [`options.clockseq = (random)`] | RFC "clock sequence" as a `Number` between 0 - 0x3fff |
168
+ | [`options.msecs = (current time)`] | RFC "timestamp" field (`Number` of milliseconds, unix epoch) |
169
+ | [`options.nsecs = 0`] | RFC "timestamp" field (`Number` of nanoseconds to add to `msecs`, should be 0-10,000) |
170
+ | [`options.random = (random)`] | `Array` of 16 random bytes (0-255) used to generate other fields, above |
171
+ | [`options.rng`] | Alternative to `options.random`, a `Function` that returns an `Array` of 16 random bytes (0-255) |
172
+ | [`buffer`] | `Uint8Array` or `Uint8Array` subtype (e.g. Node.js `Buffer`). If provided, binary UUID is written into the array, starting at `offset` |
173
+ | [`offset` = 0] | `Number` Index to start writing UUID bytes in `buffer` |
174
+ | _returns_ | UUID `String` if no `buffer` is specified, otherwise returns `buffer` |
175
+ | _throws_ | `Error` if more than 10M UUIDs/sec are requested |
184
176
 
185
177
  Example:
186
178
 
187
179
  ```javascript
188
- import { v1 as uuidv1 } from 'uuid';
180
+ import { v1 as uuidv1 } from "uuid";
189
181
 
190
- uuidv1(); // ⇨ '2c5ea4c0-4067-11e9-9b5d-ab8dfbbd4bed'
182
+ uuidv1(); // ⇨ '4d9d2960-31d0-11f1-aba8-29728d41eeed'
191
183
  ```
192
184
 
193
185
  Example using `options`:
194
186
 
195
187
  ```javascript
196
- import { v1 as uuidv1 } from 'uuid';
188
+ import { v1 as uuidv1 } from "uuid";
197
189
 
198
190
  const options = {
199
191
  node: Uint8Array.of(0x01, 0x23, 0x45, 0x67, 0x89, 0xab),
200
192
  clockseq: 0x1234,
201
- msecs: new Date('2011-11-01').getTime(),
193
+ msecs: new Date("2011-11-01").getTime(),
202
194
  nsecs: 5678,
203
195
  };
204
196
  uuidv1(options); // ⇨ '710b962e-041c-11e1-9234-0123456789ab'
@@ -209,9 +201,9 @@ uuidv1(options); // ⇨ '710b962e-041c-11e1-9234-0123456789ab'
209
201
  Convert a UUID from version 1 to version 6
210
202
 
211
203
  ```javascript
212
- import { v1ToV6 } from 'uuid';
204
+ import { v1ToV6 } from "uuid";
213
205
 
214
- v1ToV6('92f62d9e-22c4-11ef-97e9-325096b39f47'); // ⇨ '1ef22c49-2f62-6d9e-97e9-325096b39f47'
206
+ v1ToV6("92f62d9e-22c4-11ef-97e9-325096b39f47"); // ⇨ '1ef22c49-2f62-6d9e-97e9-325096b39f47'
215
207
  ```
216
208
 
217
209
  ### uuid.v3(name, namespace[, buffer[, offset]])
@@ -228,27 +220,27 @@ API is identical to `v5()`, but uses "v3" instead.
228
220
 
229
221
  Create an RFC version 4 (random) UUID
230
222
 
231
- | | |
232
- | --- | --- |
233
- | [`options`] | `Object` with one or more of the following properties: |
234
- | [`options.random`] | `Array` of 16 random bytes (0-255) |
235
- | [`options.rng`] | Alternative to `options.random`, a `Function` that returns an `Array` of 16 random bytes (0-255) |
236
- | [`buffer`] | `Uint8Array` or `Uint8Array` subtype (e.g. Node.js `Buffer`). If provided, binary UUID is written into the array, starting at `offset` |
237
- | [`offset` = 0] | `Number` Index to start writing UUID bytes in `buffer` |
238
- | _returns_ | UUID `String` if no `buffer` is specified, otherwise returns `buffer` |
223
+ | | |
224
+ | ------------------ | -------------------------------------------------------------------------------------------------------------------------------------- |
225
+ | [`options`] | `Object` with one or more of the following properties: |
226
+ | [`options.random`] | `Array` of 16 random bytes (0-255) |
227
+ | [`options.rng`] | Alternative to `options.random`, a `Function` that returns an `Array` of 16 random bytes (0-255) |
228
+ | [`buffer`] | `Uint8Array` or `Uint8Array` subtype (e.g. Node.js `Buffer`). If provided, binary UUID is written into the array, starting at `offset` |
229
+ | [`offset` = 0] | `Number` Index to start writing UUID bytes in `buffer` |
230
+ | _returns_ | UUID `String` if no `buffer` is specified, otherwise returns `buffer` |
239
231
 
240
232
  Example:
241
233
 
242
234
  ```javascript
243
- import { v4 as uuidv4 } from 'uuid';
235
+ import { v4 as uuidv4 } from "uuid";
244
236
 
245
- uuidv4(); // ⇨ '1b9d6bcd-bbfd-4b2d-9b5d-ab8dfbbd4bed'
237
+ uuidv4(); // ⇨ '7934256a-bc92-4b69-b240-f9e463881aea'
246
238
  ```
247
239
 
248
240
  Example using predefined `random` values:
249
241
 
250
242
  ```javascript
251
- import { v4 as uuidv4 } from 'uuid';
243
+ import { v4 as uuidv4 } from "uuid";
252
244
 
253
245
  const v4options = {
254
246
  random: Uint8Array.of(
@@ -267,7 +259,7 @@ const v4options = {
267
259
  0x67,
268
260
  0x1c,
269
261
  0x58,
270
- 0x36
262
+ 0x36,
271
263
  ),
272
264
  };
273
265
  uuidv4(v4options); // ⇨ '109156be-c4fb-41ea-b1b4-efe1671c5836'
@@ -277,13 +269,13 @@ uuidv4(v4options); // ⇨ '109156be-c4fb-41ea-b1b4-efe1671c5836'
277
269
 
278
270
  Create an RFC version 5 (namespace w/ SHA-1) UUID
279
271
 
280
- | | |
281
- | --- | --- |
282
- | `name` | `String \| Array` |
283
- | `namespace` | `String \| Array[16]` Namespace UUID |
284
- | [`buffer`] | `Uint8Array` or `Uint8Array` subtype (e.g. Node.js `Buffer`). If provided, binary UUID is written into the array, starting at `offset` |
285
- | [`offset` = 0] | `Number` Index to start writing UUID bytes in `buffer` |
286
- | _returns_ | UUID `String` if no `buffer` is specified, otherwise returns `buffer` |
272
+ | | |
273
+ | -------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
274
+ | `name` | `String \| Array` |
275
+ | `namespace` | `String \| Array[16]` Namespace UUID |
276
+ | [`buffer`] | `Uint8Array` or `Uint8Array` subtype (e.g. Node.js `Buffer`). If provided, binary UUID is written into the array, starting at `offset` |
277
+ | [`offset` = 0] | `Number` Index to start writing UUID bytes in `buffer` |
278
+ | _returns_ | UUID `String` if no `buffer` is specified, otherwise returns `buffer` |
287
279
 
288
280
  <!-- prettier-ignore -->
289
281
  > [!NOTE]
@@ -292,21 +284,21 @@ Create an RFC version 5 (namespace w/ SHA-1) UUID
292
284
  Example with custom namespace:
293
285
 
294
286
  ```javascript
295
- import { v5 as uuidv5 } from 'uuid';
287
+ import { v5 as uuidv5 } from "uuid";
296
288
 
297
289
  // Define a custom namespace. Readers, create your own using something like
298
290
  // https://www.uuidgenerator.net/
299
- const MY_NAMESPACE = '1b671a64-40d5-491e-99b0-da01ff1f3341';
291
+ const MY_NAMESPACE = "1b671a64-40d5-491e-99b0-da01ff1f3341";
300
292
 
301
- uuidv5('Hello, World!', MY_NAMESPACE); // ⇨ '630eb68f-e0fa-5ecc-887a-7c7a62614681'
293
+ uuidv5("Hello, World!", MY_NAMESPACE); // ⇨ '630eb68f-e0fa-5ecc-887a-7c7a62614681'
302
294
  ```
303
295
 
304
296
  Example with RFC `URL` namespace:
305
297
 
306
298
  ```javascript
307
- import { v5 as uuidv5 } from 'uuid';
299
+ import { v5 as uuidv5 } from "uuid";
308
300
 
309
- uuidv5('https://www.w3.org/', uuidv5.URL); // ⇨ 'c106a26a-21bb-5538-8bf2-57095d1976c1'
301
+ uuidv5("https://www.w3.org/", uuidv5.URL); // ⇨ 'c106a26a-21bb-5538-8bf2-57095d1976c1'
310
302
  ```
311
303
 
312
304
  ### uuid.v6([options[, buffer[, offset]]])
@@ -316,20 +308,20 @@ Create an RFC version 6 (timestamp, reordered) UUID
316
308
  This method takes the same arguments as uuid.v1().
317
309
 
318
310
  ```javascript
319
- import { v6 as uuidv6 } from 'uuid';
311
+ import { v6 as uuidv6 } from "uuid";
320
312
 
321
- uuidv6(); // ⇨ '1e940672-c5ea-64c1-9bdd-2b0d7b3dcb6d'
313
+ uuidv6(); // ⇨ '1f131d04-d9dc-65a0-9516-5be66631ce97'
322
314
  ```
323
315
 
324
316
  Example using `options`:
325
317
 
326
318
  ```javascript
327
- import { v6 as uuidv6 } from 'uuid';
319
+ import { v6 as uuidv6 } from "uuid";
328
320
 
329
321
  const options = {
330
322
  node: [0x01, 0x23, 0x45, 0x67, 0x89, 0xab],
331
323
  clockseq: 0x1234,
332
- msecs: new Date('2011-11-01').getTime(),
324
+ msecs: new Date("2011-11-01").getTime(),
333
325
  nsecs: 5678,
334
326
  };
335
327
  uuidv6(options); // ⇨ '1e1041c7-10b9-662e-9234-0123456789ab'
@@ -340,32 +332,32 @@ uuidv6(options); // ⇨ '1e1041c7-10b9-662e-9234-0123456789ab'
340
332
  Convert a UUID from version 6 to version 1
341
333
 
342
334
  ```javascript
343
- import { v6ToV1 } from 'uuid';
335
+ import { v6ToV1 } from "uuid";
344
336
 
345
- v6ToV1('1ef22c49-2f62-6d9e-97e9-325096b39f47'); // ⇨ '92f62d9e-22c4-11ef-97e9-325096b39f47'
337
+ v6ToV1("1ef22c49-2f62-6d9e-97e9-325096b39f47"); // ⇨ '92f62d9e-22c4-11ef-97e9-325096b39f47'
346
338
  ```
347
339
 
348
340
  ### uuid.v7([options[, buffer[, offset]]])
349
341
 
350
342
  Create an RFC version 7 (random) UUID
351
343
 
352
- | | |
353
- | --- | --- |
354
- | [`options`] | `Object` with one or more of the following properties: |
355
- | [`options.msecs = (current time)`] | RFC "timestamp" field (`Number` of milliseconds, unix epoch) |
356
- | [`options.random = (random)`] | `Array` of 16 random bytes (0-255) used to generate other fields, above |
357
- | [`options.rng`] | Alternative to `options.random`, a `Function` that returns an `Array` of 16 random bytes (0-255) |
358
- | [`options.seq = (random)`] | 32-bit sequence `Number` between 0 - 0xffffffff. This may be provided to help ensure uniqueness for UUIDs generated within the same millisecond time interval. Default = random value. |
359
- | [`buffer`] | `Uint8Array` or `Uint8Array` subtype (e.g. Node.js `Buffer`). If provided, binary UUID is written into the array, starting at `offset` |
360
- | [`offset` = 0] | `Number` Index to start writing UUID bytes in `buffer` |
361
- | _returns_ | UUID `String` if no `buffer` is specified, otherwise returns `buffer` |
344
+ | | |
345
+ | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
346
+ | [`options`] | `Object` with one or more of the following properties: |
347
+ | [`options.msecs = (current time)`] | RFC "timestamp" field (`Number` of milliseconds, unix epoch) |
348
+ | [`options.random = (random)`] | `Array` of 16 random bytes (0-255) used to generate other fields, above |
349
+ | [`options.rng`] | Alternative to `options.random`, a `Function` that returns an `Array` of 16 random bytes (0-255) |
350
+ | [`options.seq = (random)`] | 32-bit sequence `Number` between 0 - 0xffffffff. This may be provided to help ensure uniqueness for UUIDs generated within the same millisecond time interval. Default = random value. |
351
+ | [`buffer`] | `Uint8Array` or `Uint8Array` subtype (e.g. Node.js `Buffer`). If provided, binary UUID is written into the array, starting at `offset` |
352
+ | [`offset` = 0] | `Number` Index to start writing UUID bytes in `buffer` |
353
+ | _returns_ | UUID `String` if no `buffer` is specified, otherwise returns `buffer` |
362
354
 
363
355
  Example:
364
356
 
365
357
  ```javascript
366
- import { v7 as uuidv7 } from 'uuid';
358
+ import { v7 as uuidv7 } from "uuid";
367
359
 
368
- uuidv7(); // ⇨ '01695553-c90c-745a-b76f-770d7b3dcb6d'
360
+ uuidv7(); // ⇨ '019d637c-c6fb-74e9-8b9d-2f1d459a4201'
369
361
  ```
370
362
 
371
363
  ### ~~uuid.v8()~~
@@ -388,24 +380,24 @@ Test a string to see if it is a valid UUID
388
380
  Example:
389
381
 
390
382
  ```javascript
391
- import { validate as uuidValidate } from 'uuid';
383
+ import { validate as uuidValidate } from "uuid";
392
384
 
393
- uuidValidate('not a UUID'); // ⇨ false
394
- uuidValidate('6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b'); // ⇨ true
385
+ uuidValidate("not a UUID"); // ⇨ false
386
+ uuidValidate("6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b"); // ⇨ true
395
387
  ```
396
388
 
397
389
  Using `validate` and `version` together it is possible to do per-version validation, e.g. validate for only v4 UUIds.
398
390
 
399
391
  ```javascript
400
- import { version as uuidVersion } from 'uuid';
401
- import { validate as uuidValidate } from 'uuid';
392
+ import { version as uuidVersion } from "uuid";
393
+ import { validate as uuidValidate } from "uuid";
402
394
 
403
395
  function uuidValidateV4(uuid) {
404
396
  return uuidValidate(uuid) && uuidVersion(uuid) === 4;
405
397
  }
406
398
 
407
- const v1Uuid = 'd9428888-122b-11e1-b85c-61cd3cbb3210';
408
- const v4Uuid = '109156be-c4fb-41ea-b1b4-efe1671c5836';
399
+ const v1Uuid = "d9428888-122b-11e1-b85c-61cd3cbb3210";
400
+ const v4Uuid = "109156be-c4fb-41ea-b1b4-efe1671c5836";
409
401
 
410
402
  uuidValidateV4(v4Uuid); // ⇨ true
411
403
  uuidValidateV4(v1Uuid); // ⇨ false
@@ -424,10 +416,10 @@ Detect RFC version of a UUID
424
416
  Example:
425
417
 
426
418
  ```javascript
427
- import { version as uuidVersion } from 'uuid';
419
+ import { version as uuidVersion } from "uuid";
428
420
 
429
- uuidVersion('45637ec4-c85f-11ea-87d0-0242ac130003'); // ⇨ 1
430
- uuidVersion('6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b'); // ⇨ 4
421
+ uuidVersion("45637ec4-c85f-11ea-87d0-0242ac130003"); // ⇨ 1
422
+ uuidVersion("6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b"); // ⇨ 4
431
423
  ```
432
424
 
433
425
  <!-- prettier-ignore -->
@@ -472,13 +464,13 @@ Prior to `uuid@11`, it was possible for `options` state to interfere with the in
472
464
 
473
465
  **Browsers**: `uuid` [builds are tested](/uuidjs/uuid/blob/main/wdio.conf.js) against the latest version of desktop Chrome, Safari, Firefox, and Edge. Mobile versions of these same browsers are expected to work but aren't currently tested.
474
466
 
475
- **Node**: `uuid` [builds are tested](https://github.com/uuidjs/uuid/blob/main/.github/workflows/ci.yml#L26-L27) against node ([LTS releases](https://github.com/nodejs/Release)), plus one prior. E.g. At the time of this writing `node@20` is the "maintenance" release and `node@24` is the "current" release, so `uuid` supports `node@18`-`node@24`.
467
+ **Node**: `uuid` [builds are tested](https://github.com/uuidjs/uuid/blob/main/.github/workflows/ci.yml#L26-L27) against node ([LTS releases](https://github.com/nodejs/Release)), plus one prior. E.g. At the time of this writing `node@20` is the "maintenance" release and `node@24` is the "current" release, so `uuid` supports `node@20`-`node@24`.
476
468
 
477
469
  **Typescript**: TS versions released within the past two years are supported. [source](https://github.com/microsoft/TypeScript/issues/49088#issuecomment-2468723715)
478
470
 
479
471
  ## Known issues
480
472
 
481
- <!-- This header is referenced as an anchor in src/rng-browser.ts -->
473
+ <!-- This header is referenced as an anchor in src/rng.ts -->
482
474
 
483
475
  ### "getRandomValues() not supported"
484
476
 
@@ -490,8 +482,8 @@ This error occurs in environments where the standard [`crypto.getRandomValues()`
490
482
  1. Import it _before_ `uuid`. Since `uuid` might also appear as a transitive dependency of some other imports it's safest to just import `react-native-get-random-values` as the very first thing in your entry point:
491
483
 
492
484
  ```javascript
493
- import 'react-native-get-random-values';
494
- import { v4 as uuidv4 } from 'uuid';
485
+ import "react-native-get-random-values";
486
+ import { v4 as uuidv4 } from "uuid";
495
487
  ```
496
488
 
497
489
  ---
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- export type * from './types.js';
2
1
  export { default as MAX } from './max.js';
3
2
  export { default as NIL } from './nil.js';
4
3
  export { default as parse } from './parse.js';
5
4
  export { default as stringify } from './stringify.js';
5
+ export type * from './types.js';
6
6
  export { default as v1 } from './v1.js';
7
7
  export { default as v1ToV6 } from './v1ToV6.js';
8
8
  export { default as v3 } from './v3.js';
package/dist/md5.js CHANGED
@@ -16,7 +16,7 @@ function getOutputLength(inputLength8) {
16
16
  function wordsToMd5(x, len) {
17
17
  const xpad = new Uint32Array(getOutputLength(len)).fill(0);
18
18
  xpad.set(x);
19
- xpad[len >> 5] |= 0x80 << len % 32;
19
+ xpad[len >> 5] |= 0x80 << (len % 32);
20
20
  xpad[xpad.length - 1] = len;
21
21
  x = xpad;
22
22
  let a = 1732584193;
package/dist/parse.d.ts CHANGED
@@ -1,2 +1,3 @@
1
- declare function parse(uuid: string): Uint8Array;
1
+ import type { NonSharedArrayBuffer } from './types.js';
2
+ declare function parse(uuid: string): NonSharedArrayBuffer;
2
3
  export default parse;
package/dist/rng.js CHANGED
@@ -1,11 +1,4 @@
1
- let getRandomValues;
2
1
  const rnds8 = new Uint8Array(16);
3
2
  export default function rng() {
4
- if (!getRandomValues) {
5
- if (typeof crypto === 'undefined' || !crypto.getRandomValues) {
6
- throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
7
- }
8
- getRandomValues = crypto.getRandomValues.bind(crypto);
9
- }
10
- return getRandomValues(rnds8);
3
+ return crypto.getRandomValues(rnds8);
11
4
  }
package/dist/sha1.js CHANGED
@@ -34,7 +34,7 @@ function sha1(bytes) {
34
34
  }
35
35
  M[i] = arr;
36
36
  }
37
- M[N - 1][14] = ((bytes.length - 1) * 8) / Math.pow(2, 32);
37
+ M[N - 1][14] = ((bytes.length - 1) * 8) / 2 ** 32;
38
38
  M[N - 1][14] = Math.floor(M[N - 1][14]);
39
39
  M[N - 1][15] = ((bytes.length - 1) * 8) & 0xffffffff;
40
40
  for (let i = 0; i < N; ++i) {
package/dist/types.d.ts CHANGED
@@ -19,3 +19,4 @@ export type Version7Options = {
19
19
  seq?: number;
20
20
  rng?: () => Uint8Array;
21
21
  };
22
+ export type NonSharedArrayBuffer = ReturnType<typeof Uint8Array.of>;
package/dist/v1.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Version1Options } from './types.js';
1
+ import type { Version1Options } from './types.js';
2
2
  type V1State = {
3
3
  node?: Uint8Array;
4
4
  clockseq?: number;
package/dist/v1ToV6.d.ts CHANGED
@@ -1,2 +1,3 @@
1
+ import type { NonSharedArrayBuffer } from './types.js';
1
2
  export default function v1ToV6(uuid: string): string;
2
- export default function v1ToV6(uuid: Uint8Array): Uint8Array;
3
+ export default function v1ToV6(uuid: Uint8Array): NonSharedArrayBuffer;
package/dist/v3.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { UUIDTypes } from './types.js';
1
+ import type { UUIDTypes } from './types.js';
2
2
  export { DNS, URL } from './v35.js';
3
3
  declare function v3(value: string | Uint8Array, namespace: UUIDTypes, buf?: undefined, offset?: number): string;
4
4
  declare function v3<TBuf extends Uint8Array = Uint8Array>(value: string | Uint8Array, namespace: UUIDTypes, buf: TBuf, offset?: number): TBuf;
package/dist/v35.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { UUIDTypes } from './types.js';
1
+ import type { UUIDTypes } from './types.js';
2
2
  export declare function stringToBytes(str: string): Uint8Array;
3
3
  export declare const DNS = "6ba7b810-9dad-11d1-80b4-00c04fd430c8";
4
4
  export declare const URL = "6ba7b811-9dad-11d1-80b4-00c04fd430c8";
package/dist/v35.js CHANGED
@@ -26,7 +26,10 @@ export default function v35(version, hash, value, namespace, buf, offset) {
26
26
  bytes[6] = (bytes[6] & 0x0f) | version;
27
27
  bytes[8] = (bytes[8] & 0x3f) | 0x80;
28
28
  if (buf) {
29
- offset = offset || 0;
29
+ offset ??= 0;
30
+ if (offset < 0 || offset + 16 > buf.length) {
31
+ throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
32
+ }
30
33
  for (let i = 0; i < 16; ++i) {
31
34
  buf[offset + i] = bytes[i];
32
35
  }
package/dist/v4.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Version4Options } from './types.js';
1
+ import type { Version4Options } from './types.js';
2
2
  declare function v4(options?: Version4Options, buf?: undefined, offset?: number): string;
3
3
  declare function v4<TBuf extends Uint8Array = Uint8Array>(options: Version4Options | undefined, buf: TBuf, offset?: number): TBuf;
4
4
  export default v4;
package/dist/v4.js CHANGED
@@ -1,6 +1,11 @@
1
- import native from './native.js';
2
1
  import rng from './rng.js';
3
2
  import { unsafeStringify } from './stringify.js';
3
+ function v4(options, buf, offset) {
4
+ if (!buf && !options && crypto.randomUUID) {
5
+ return crypto.randomUUID();
6
+ }
7
+ return _v4(options, buf, offset);
8
+ }
4
9
  function _v4(options, buf, offset) {
5
10
  options = options || {};
6
11
  const rnds = options.random ?? options.rng?.() ?? rng();
@@ -21,10 +26,4 @@ function _v4(options, buf, offset) {
21
26
  }
22
27
  return unsafeStringify(rnds);
23
28
  }
24
- function v4(options, buf, offset) {
25
- if (native.randomUUID && !buf && !options) {
26
- return native.randomUUID();
27
- }
28
- return _v4(options, buf, offset);
29
- }
30
29
  export default v4;
package/dist/v5.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { UUIDTypes } from './types.js';
1
+ import type { UUIDTypes } from './types.js';
2
2
  export { DNS, URL } from './v35.js';
3
3
  declare function v5(value: string | Uint8Array, namespace: UUIDTypes, buf?: undefined, offset?: number): string;
4
4
  declare function v5<TBuf extends Uint8Array = Uint8Array>(value: string | Uint8Array, namespace: UUIDTypes, buf: TBuf, offset?: number): TBuf;
package/dist/v6.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Version6Options } from './types.js';
1
+ import type { Version6Options } from './types.js';
2
2
  declare function v6(options?: Version6Options, buf?: undefined, offset?: number): string;
3
3
  declare function v6<TBuf extends Uint8Array = Uint8Array>(options: Version6Options | undefined, buf: TBuf, offset?: number): TBuf;
4
4
  export default v6;
package/dist/v6.js CHANGED
@@ -7,6 +7,9 @@ function v6(options, buf, offset) {
7
7
  let bytes = v1({ ...options, _v6: true }, new Uint8Array(16));
8
8
  bytes = v1ToV6(bytes);
9
9
  if (buf) {
10
+ if (offset < 0 || offset + 16 > buf.length) {
11
+ throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
12
+ }
10
13
  for (let i = 0; i < 16; i++) {
11
14
  buf[offset + i] = bytes[i];
12
15
  }
package/dist/v7.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Version7Options } from './types.js';
1
+ import type { Version7Options } from './types.js';
2
2
  type V7State = {
3
3
  msecs?: number;
4
4
  seq?: number;
package/dist-node/rng.js CHANGED
@@ -1,10 +1,4 @@
1
- import { randomFillSync } from 'node:crypto';
2
- const rnds8Pool = new Uint8Array(256);
3
- let poolPtr = rnds8Pool.length;
1
+ const rnds8 = new Uint8Array(16);
4
2
  export default function rng() {
5
- if (poolPtr > rnds8Pool.length - 16) {
6
- randomFillSync(rnds8Pool);
7
- poolPtr = 0;
8
- }
9
- return rnds8Pool.slice(poolPtr, (poolPtr += 16));
3
+ return crypto.getRandomValues(rnds8);
10
4
  }
package/dist-node/v35.js CHANGED
@@ -26,7 +26,10 @@ export default function v35(version, hash, value, namespace, buf, offset) {
26
26
  bytes[6] = (bytes[6] & 0x0f) | version;
27
27
  bytes[8] = (bytes[8] & 0x3f) | 0x80;
28
28
  if (buf) {
29
- offset = offset || 0;
29
+ offset ??= 0;
30
+ if (offset < 0 || offset + 16 > buf.length) {
31
+ throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
32
+ }
30
33
  for (let i = 0; i < 16; ++i) {
31
34
  buf[offset + i] = bytes[i];
32
35
  }
package/dist-node/v4.js CHANGED
@@ -1,6 +1,11 @@
1
- import native from './native.js';
2
1
  import rng from './rng.js';
3
2
  import { unsafeStringify } from './stringify.js';
3
+ function v4(options, buf, offset) {
4
+ if (!buf && !options && crypto.randomUUID) {
5
+ return crypto.randomUUID();
6
+ }
7
+ return _v4(options, buf, offset);
8
+ }
4
9
  function _v4(options, buf, offset) {
5
10
  options = options || {};
6
11
  const rnds = options.random ?? options.rng?.() ?? rng();
@@ -21,10 +26,4 @@ function _v4(options, buf, offset) {
21
26
  }
22
27
  return unsafeStringify(rnds);
23
28
  }
24
- function v4(options, buf, offset) {
25
- if (native.randomUUID && !buf && !options) {
26
- return native.randomUUID();
27
- }
28
- return _v4(options, buf, offset);
29
- }
30
29
  export default v4;
package/dist-node/v6.js CHANGED
@@ -7,6 +7,9 @@ function v6(options, buf, offset) {
7
7
  let bytes = v1({ ...options, _v6: true }, new Uint8Array(16));
8
8
  bytes = v1ToV6(bytes);
9
9
  if (buf) {
10
+ if (offset < 0 || offset + 16 > buf.length) {
11
+ throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
12
+ }
10
13
  for (let i = 0; i < 16; i++) {
11
14
  buf[offset + i] = bytes[i];
12
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uuid",
3
- "version": "13.0.0",
3
+ "version": "14.0.0",
4
4
  "description": "RFC9562 UUIDs",
5
5
  "type": "module",
6
6
  "funding": [
@@ -37,35 +37,29 @@
37
37
  "!**/test"
38
38
  ],
39
39
  "devDependencies": {
40
- "@babel/eslint-parser": "7.27.1",
41
- "@commitlint/cli": "19.8.0",
42
- "@commitlint/config-conventional": "19.8.0",
43
- "@eslint/js": "9.26.0",
40
+ "@biomejs/biome": "2.4.10",
41
+ "@commitlint/cli": "20.5.0",
42
+ "@commitlint/config-conventional": "20.5.0",
44
43
  "bundlewatch": "0.4.1",
45
- "commander": "13.1.0",
46
- "eslint": "9.26.0",
47
- "eslint-config-prettier": "10.1.2",
48
- "eslint-plugin-prettier": "5.4.0",
49
- "globals": "16.0.0",
44
+ "commander": "14.0.3",
45
+ "globals": "17.4.0",
50
46
  "husky": "9.1.7",
51
- "jest": "29.7.0",
52
- "lint-staged": "15.5.2",
53
- "neostandard": "0.12.1",
54
- "npm-run-all": "4.1.5",
55
- "prettier": "3.5.3",
56
- "release-please": "17.0.0",
47
+ "jest": "30.3.0",
48
+ "lint-staged": "16.4.0",
49
+ "neostandard": "0.13.0",
50
+ "npm-run-all2": "8.0.4",
51
+ "release-please": "17.3.0",
57
52
  "runmd": "1.4.1",
58
53
  "standard-version": "9.5.0",
59
- "typescript": "5.2.2",
60
- "typescript-eslint": "8.32.0"
54
+ "typescript": "5.4.3"
61
55
  },
62
56
  "optionalDevDependencies": {
63
- "@wdio/browserstack-service": "9.2.1",
64
- "@wdio/cli": "9.2.1",
65
- "@wdio/jasmine-framework": "9.2.1",
66
- "@wdio/local-runner": "9.2.1",
67
- "@wdio/spec-reporter": "9.1.3",
68
- "@wdio/static-server-service": "9.1.3"
57
+ "@wdio/browserstack-service": "9.27.0",
58
+ "@wdio/cli": "9.27.0",
59
+ "@wdio/jasmine-framework": "9.27.0",
60
+ "@wdio/local-runner": "9.27.0",
61
+ "@wdio/spec-reporter": "9.27.0",
62
+ "@wdio/static-server-service": "9.27.0"
69
63
  },
70
64
  "scripts": {
71
65
  "build": "./scripts/build.sh",
@@ -73,14 +67,14 @@
73
67
  "bundlewatch": "npm run pretest:browser && bundlewatch --config bundlewatch.config.json",
74
68
  "docs:diff": "npm run docs && git diff --quiet -I \"[0-9a-f-]{36}\" README.md",
75
69
  "docs": "npm run build && npx runmd --output=README.md README_js.md",
76
- "eslint:check": "eslint src/ test/ examples/ *.[jt]s",
77
- "eslint:fix": "eslint --fix src/ test/ examples/ *.[jt]s",
70
+ "biome:check": "biome check .",
71
+ "biome:fix": "biome check --write .",
78
72
  "examples:browser:rollup:build": "cd examples/browser-rollup && npm run build",
79
73
  "examples:browser:webpack:build": "cd examples/browser-webpack && npm run build",
80
74
  "examples:node:esmodules:test": "cd examples/node-esmodules && npm test",
81
75
  "examples:node:jest:test": "cd examples/node-jest && npm test",
82
76
  "examples:node:typescript:test": "cd examples/typescript && npm test",
83
- "lint": "npm run eslint:check && npm run prettier:check",
77
+ "lint": "npm run biome:check",
84
78
  "md": "runmd --watch --output=README.md README_js.md",
85
79
  "prepack": "npm run build -- --no-pack",
86
80
  "prepare": "husky",
@@ -89,8 +83,8 @@
89
83
  "pretest:browser": "./scripts/iodd && npm run build && npm-run-all --parallel examples:browser:**",
90
84
  "pretest:node": "npm run build",
91
85
  "pretest": "npm run build",
92
- "prettier:check": "prettier --check .",
93
- "prettier:fix": "prettier --write .",
86
+ "format": "biome format --write .",
87
+ "format:check": "biome format --check .",
94
88
  "release": "standard-version --no-verify",
95
89
  "test:benchmark": "cd examples/benchmark && npm test",
96
90
  "test:browser": "wdio run ./wdio.conf.js",
@@ -104,16 +98,13 @@
104
98
  },
105
99
  "lint-staged": {
106
100
  "*": [
107
- "prettier --no-error-on-unmatched-pattern --write"
108
- ],
109
- "*.{js,jsx}": [
110
- "eslint --no-error-on-unmatched-pattern --fix"
101
+ "biome check --write --no-errors-on-unmatched"
111
102
  ]
112
103
  },
113
104
  "standard-version": {
114
105
  "scripts": {
115
- "postchangelog": "prettier --write CHANGELOG.md"
106
+ "postchangelog": "biome format --write CHANGELOG.md"
116
107
  }
117
108
  },
118
- "packageManager": "npm@11.3.0"
109
+ "packageManager": "npm@11.12.1"
119
110
  }
package/dist/native.d.ts DELETED
@@ -1,4 +0,0 @@
1
- declare const _default: {
2
- randomUUID: false | (() => `${string}-${string}-${string}-${string}-${string}`);
3
- };
4
- export default _default;
package/dist/native.js DELETED
@@ -1,2 +0,0 @@
1
- const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
2
- export default { randomUUID };
@@ -1,2 +0,0 @@
1
- import { randomUUID } from 'node:crypto';
2
- export default { randomUUID };