@@ -21,7 +21,7 @@ require('crypto').randomUUID = undefined;
21
21
22
22
For the creation of [ RFC4122] ( https://www.ietf.org/rfc/rfc4122.txt ) UUIDs
23
23
24
- - ** Complete** - Support for RFC4122 version 1, 3, 4, and 5 UUIDs
24
+ - ** Complete** - Support for RFC4122 version 1, 3, 4, 5, and 7 UUIDs
25
25
- ** Cross-platform** - Support for ...
26
26
- CommonJS, [ ECMAScript Modules] ( #ecmascript-modules ) and [ CDN builds] ( #cdn-builds )
27
27
- NodeJS 12+ ([ LTS releases] ( https://github.com/nodejs/Release ) )
@@ -73,6 +73,7 @@ For timestamp UUIDs, namespace UUIDs, and other options read on ...
73
73
| [ ` uuid.v3() ` ] ( #uuidv3name-namespace-buffer-offset ) | Create a version 3 (namespace w/ MD5) UUID | |
74
74
| [ ` uuid.v4() ` ] ( #uuidv4options-buffer-offset ) | Create a version 4 (random) UUID | |
75
75
| [ ` uuid.v5() ` ] ( #uuidv5name-namespace-buffer-offset ) | Create a version 5 (namespace w/ SHA-1) UUID | |
76
+ | [ ` uuid.v7() ` ] ( #uuidv7options-buffer-offset ) | Create a version 7 (Unix Epoch time-based) UUID | ` experimental support ` |
76
77
| [ ` uuid.validate() ` ] ( #uuidvalidatestr ) | Test a string to see if it is a valid UUID
| New in
` [email protected] ` |
77
78
| [ ` uuid.version() ` ] ( #uuidversionstr ) | Detect RFC version of a UUID
| New in
` [email protected] ` |
78
79
@@ -259,6 +260,29 @@ import { v5 as uuidv5 } from 'uuid';
259
260
uuidv5 (' https://www.w3.org/' , uuidv5 .URL ); // RESULT
260
261
```
261
262
263
+ ### uuid.v7([ options[ , buffer[ , offset]]] )
264
+
265
+ Create an RFC version 7 (random) UUID
266
+
267
+ | | |
268
+ | --- | --- |
269
+ | [ ` options ` ] | ` Object ` with one or more of the following properties: |
270
+ | [ ` options.msecs ` ] | RFC "timestamp" field (` Number ` of milliseconds, unix epoch) |
271
+ | [ ` options.random ` ] | ` Array ` of 16 random bytes (0-255) |
272
+ | [ ` options.rng ` ] | Alternative to ` options.random ` , a ` Function ` that returns an ` Array ` of 16 random bytes (0-255) |
273
+ | [ ` options.seq ` ] | 31 bit monotonic sequence counter as ` Number ` between 0 - 0x7fffffff |
274
+ | [ ` buffer ` ] | ` Array \| Buffer ` If specified, uuid will be written here in byte-form, starting at ` offset ` |
275
+ | [ ` offset ` = 0] | ` Number ` Index to start writing UUID bytes in ` buffer ` |
276
+ | _ returns_ | UUID ` String ` if no ` buffer ` is specified, otherwise returns ` buffer ` |
277
+
278
+ Example:
279
+
280
+ ``` javascript --run
281
+ import { v7 as uuidv7 } from ' uuid' ;
282
+
283
+ uuidv7 (); // RESULT
284
+ ```
285
+
262
286
### uuid.validate(str)
263
287
264
288
Test a string to see if it is a valid UUID
@@ -333,6 +357,7 @@ Usage:
333
357
uuid v3 < name> < namespace uuid>
334
358
uuid v4
335
359
uuid v5 < name> < namespace uuid>
360
+ uuid v7
336
361
uuid --help
337
362
338
363
Note: < namespace uuid> may be " URL" or " DNS" to use the corresponding UUIDs
0 commit comments