@@ -21,7 +21,7 @@ require('crypto').randomUUID = undefined;
2121
2222For the creation of [ RFC4122] ( https://www.ietf.org/rfc/rfc4122.txt ) UUIDs
2323
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
2525- ** Cross-platform** - Support for ...
2626 - CommonJS, [ ECMAScript Modules] ( #ecmascript-modules ) and [ CDN builds] ( #cdn-builds )
2727 - NodeJS 12+ ([ LTS releases] ( https://github.com/nodejs/Release ) )
@@ -73,6 +73,7 @@ For timestamp UUIDs, namespace UUIDs, and other options read on ...
7373| [ ` uuid.v3() ` ] ( #uuidv3name-namespace-buffer-offset ) | Create a version 3 (namespace w/ MD5) UUID | |
7474| [ ` uuid.v4() ` ] ( #uuidv4options-buffer-offset ) | Create a version 4 (random) UUID | |
7575| [ ` 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 ` |
7677| [ ` uuid.validate() ` ] ( #uuidvalidatestr ) | Test a string to see if it is a valid UUID
| New in
` [email protected] ` | 7778| [ ` uuid.version() ` ] ( #uuidversionstr ) | Detect RFC version of a UUID
| New in
` [email protected] ` | 7879
@@ -259,6 +260,29 @@ import { v5 as uuidv5 } from 'uuid';
259260uuidv5 (' https://www.w3.org/' , uuidv5 .URL ); // RESULT
260261```
261262
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+
262286### uuid.validate(str)
263287
264288Test a string to see if it is a valid UUID
@@ -333,6 +357,7 @@ Usage:
333357 uuid v3 < name> < namespace uuid>
334358 uuid v4
335359 uuid v5 < name> < namespace uuid>
360+ uuid v7
336361 uuid --help
337362
338363Note: < namespace uuid> may be " URL" or " DNS" to use the corresponding UUIDs
0 commit comments