-
-
Notifications
You must be signed in to change notification settings - Fork 941
feat: support v6 uuids #754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from 12 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
9b365da
feat: support v6 uuids
broofa 8aeee27
fix: test and comment
broofa 6eebe89
test: add v1<->v6 utilities to browser tests
broofa a69f436
fix: filenames and lint flags
broofa f4cf3e8
chore: upgrade husky dependency
broofa 4710dee
chore: revert bundlewatch config
broofa f7efb7f
feat: add v6 method
broofa f5c6018
fix: make browser test more resilient to test order
broofa 18cff2e
chore: revise v6 implementation
broofa 09e269d
docs: update with v6 API
broofa 3c35893
chore: update v6 bundlewatch size
broofa d09e432
docs: v6 uuid
broofa b510bac
Merge branch 'main' into v1v6
broofa 7d206b4
chore: v6 bundlewatch size
broofa e06069d
Merge branch 'main' into v1v6
broofa e94c947
fix: add .local/v6.js
broofa ac6bfdb
chore: gitignore vscode
broofa fdab55f
chore: rm vscode dir
broofa 5df758e
chore: update comments
broofa 08d9303
fix: pr feedback
broofa 0212b6e
docs: fix broken anchor refs
broofa fe81cbb
docs: typo
broofa 5d54310
docs: fix regression
broofa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../../v1tov6.js |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../../v6tov1.js |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "files.autoSave": "afterDelay", | ||
| "editor.formatOnSave": false, | ||
| "editor.defaultFormatter": "esbenp.prettier-vscode" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,10 +61,13 @@ For timestamp UUIDs, namespace UUIDs, and other options read on ... | |
| | [`uuid.parse()`](#uuidparsestr) | Convert UUID string to array of bytes | New in `[email protected]` | | ||
| | [`uuid.stringify()`](#uuidstringifyarr-offset) | Convert array of bytes to UUID string | New in `[email protected]` | | ||
| | [`uuid.v1()`](#uuidv1options-buffer-offset) | Create a version 1 (timestamp) UUID | | | ||
| | [`uuid.v1ToV6()`](#uuidv7options-buffer-offset) | Create a version 6 UUID from a version 1 UUID | New in `uuid@10` | | ||
| | [`uuid.v3()`](#uuidv3name-namespace-buffer-offset) | Create a version 3 (namespace w/ MD5) UUID | | | ||
| | [`uuid.v4()`](#uuidv4options-buffer-offset) | Create a version 4 (random) UUID | | | ||
| | [`uuid.v5()`](#uuidv5name-namespace-buffer-offset) | Create a version 5 (namespace w/ SHA-1) UUID | | | ||
| | [`uuid.v7()`](#uuidv7options-buffer-offset) | Create a version 7 (Unix Epoch time-based) UUID | `experimental support` | | ||
| | [`uuid.v6()`](#uuidv5name-namespace-buffer-offset) | Create a version 6 (timestamp, reordered) UUID | New in `uuid@10` | | ||
| | [`uuid.v6ToV1()`](#uuidv7options-buffer-offset) | Create a version 1 UUID from a version 6 UUID | New in `uuid@10` | | ||
| | [`uuid.v7()`](#uuidv7options-buffer-offset) | Create a version 7 (Unix Epoch time-based) UUID | New in `uuid@10` | | ||
| | [`uuid.validate()`](#uuidvalidatestr) | Test a string to see if it is a valid UUID | New in `[email protected]` | | ||
| | [`uuid.version()`](#uuidversionstr) | Detect RFC version of a UUID | New in `[email protected]` | | ||
|
|
||
|
|
@@ -201,6 +204,16 @@ const v1options = { | |
| uuidv1(v1options); // ⇨ '710b962e-041c-11e1-9234-0123456789ab' | ||
| ``` | ||
|
|
||
| ### uuid.v1ToV6(uuid) | ||
|
|
||
| Convert a UUID from version 1 to version 6 | ||
|
|
||
| ```javascript | ||
| import { v1ToV6 } from 'uuid'; | ||
|
|
||
| v1ToV6('92f62d9e-22c4-11ef-97e9-325096b39f47'); // ⇨ '1ef22c49-2f62-6d9e-97e9-325096b39f47' | ||
| ``` | ||
|
|
||
| ### uuid.v3(name, namespace[, buffer[, offset]]) | ||
|
|
||
| Create an RFC version 3 (namespace w/ MD5) UUID | ||
|
|
@@ -281,6 +294,42 @@ import { v5 as uuidv5 } from 'uuid'; | |
| uuidv5('https://www.w3.org/', uuidv5.URL); // ⇨ 'c106a26a-21bb-5538-8bf2-57095d1976c1' | ||
| ``` | ||
|
|
||
| ### uuid.v6([options, [, buffer[, offset]]]) | ||
|
|
||
| Create an RFC version 6 (timestamp, reordered) UUID | ||
|
|
||
| This method takes the same args as uuid.v1(). | ||
|
|
||
| ```javascript | ||
| import { v6 as uuidv6 } from 'uuid'; | ||
|
|
||
| uuidv6(); // ⇨ '1e940672-c5ea-64c0-8bad-9b1deb4d3b7d' | ||
| ``` | ||
|
|
||
| Example using `options`: | ||
|
|
||
| ```javascript | ||
| import { v6 as uuidv6 } from 'uuid'; | ||
|
|
||
| const v1options = { | ||
| node: [0x01, 0x23, 0x45, 0x67, 0x89, 0xab], | ||
| clockseq: 0x1234, | ||
| msecs: new Date('2011-11-01').getTime(), | ||
| nsecs: 5678, | ||
| }; | ||
| uuidv6(v1options); // ⇨ '1e1041c7-10b9-662e-9234-0123456789ab' | ||
| ``` | ||
|
|
||
| ### uuid.v6ToV1(uuid) | ||
|
|
||
| Convert a UUID from version 6 to version 1 | ||
|
|
||
| ```javascript | ||
| import { v6ToV1 } from 'uuid'; | ||
|
|
||
| v6ToV1('92f62d9e-22c4-11ef-97e9-325096b39f47'); // ⇨ 'e22c41ef-62d9-192f-97e9-325096b39f47' | ||
| ``` | ||
|
|
||
| ### uuid.v7([options[, buffer[, offset]]]) | ||
|
|
||
| Create an RFC version 7 (random) UUID | ||
|
|
@@ -301,7 +350,7 @@ Example: | |
| ```javascript | ||
| import { v7 as uuidv7 } from 'uuid'; | ||
|
|
||
| uuidv7(); // ⇨ '01695553-c90c-7aad-9bdd-330d7b3dcb6d' | ||
| uuidv7(); // ⇨ '01695553-c90c-722d-9b5d-b38dfbbd4bed' | ||
| ``` | ||
|
|
||
| ### uuid.validate(str) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -75,10 +75,13 @@ For timestamp UUIDs, namespace UUIDs, and other options read on ... | |
| | [`uuid.parse()`](#uuidparsestr) | Convert UUID string to array of bytes | New in `[email protected]` | | ||
| | [`uuid.stringify()`](#uuidstringifyarr-offset) | Convert array of bytes to UUID string | New in `[email protected]` | | ||
| | [`uuid.v1()`](#uuidv1options-buffer-offset) | Create a version 1 (timestamp) UUID | | | ||
| | [`uuid.v1ToV6()`](#uuidv7options-buffer-offset) | Create a version 6 UUID from a version 1 UUID | New in `uuid@10` | | ||
| | [`uuid.v3()`](#uuidv3name-namespace-buffer-offset) | Create a version 3 (namespace w/ MD5) UUID | | | ||
| | [`uuid.v4()`](#uuidv4options-buffer-offset) | Create a version 4 (random) UUID | | | ||
| | [`uuid.v5()`](#uuidv5name-namespace-buffer-offset) | Create a version 5 (namespace w/ SHA-1) UUID | | | ||
| | [`uuid.v7()`](#uuidv7options-buffer-offset) | Create a version 7 (Unix Epoch time-based) UUID | `experimental support` | | ||
| | [`uuid.v6()`](#uuidv5name-namespace-buffer-offset) | Create a version 6 (timestamp, reordered) UUID | New in `uuid@10` | | ||
| | [`uuid.v6ToV1()`](#uuidv7options-buffer-offset) | Create a version 1 UUID from a version 6 UUID | New in `uuid@10` | | ||
| | [`uuid.v7()`](#uuidv7options-buffer-offset) | Create a version 7 (Unix Epoch time-based) UUID | New in `uuid@10` | | ||
| | [`uuid.validate()`](#uuidvalidatestr) | Test a string to see if it is a valid UUID | New in `[email protected]` | | ||
| | [`uuid.version()`](#uuidversionstr) | Detect RFC version of a UUID | New in `[email protected]` | | ||
|
|
||
|
|
@@ -209,6 +212,16 @@ const v1options = { | |
| uuidv1(v1options); // RESULT | ||
| ``` | ||
|
|
||
| ### uuid.v1ToV6(uuid) | ||
|
|
||
| Convert a UUID from version 1 to version 6 | ||
|
|
||
| ```javascript --run | ||
| import { v1ToV6 } from 'uuid'; | ||
|
|
||
| v1ToV6('92f62d9e-22c4-11ef-97e9-325096b39f47'); // RESULT | ||
| ``` | ||
|
|
||
| ### uuid.v3(name, namespace[, buffer[, offset]]) | ||
|
|
||
| Create an RFC version 3 (namespace w/ MD5) UUID | ||
|
|
@@ -289,6 +302,42 @@ import { v5 as uuidv5 } from 'uuid'; | |
| uuidv5('https://www.w3.org/', uuidv5.URL); // RESULT | ||
| ``` | ||
|
|
||
| ### uuid.v6([options, [, buffer[, offset]]]) | ||
|
|
||
| Create an RFC version 6 (timestamp, reordered) UUID | ||
|
|
||
| This method takes the same args as uuid.v1(). | ||
|
|
||
| ```javascript --run | ||
| import { v6 as uuidv6 } from 'uuid'; | ||
|
|
||
| uuidv6(); // RESULT | ||
| ``` | ||
|
|
||
| Example using `options`: | ||
|
|
||
| ```javascript --run | ||
| import { v6 as uuidv6 } from 'uuid'; | ||
|
|
||
| const v1options = { | ||
| node: [0x01, 0x23, 0x45, 0x67, 0x89, 0xab], | ||
| clockseq: 0x1234, | ||
| msecs: new Date('2011-11-01').getTime(), | ||
| nsecs: 5678, | ||
| }; | ||
| uuidv6(v1options); // RESULT | ||
| ``` | ||
|
|
||
| ### uuid.v6ToV1(uuid) | ||
|
|
||
| Convert a UUID from version 6 to version 1 | ||
|
|
||
| ```javascript --run | ||
| import { v6ToV1 } from 'uuid'; | ||
|
|
||
| v6ToV1('1ef22c49-2f62-6d9e-97e9-325096b39f47'); // RESULT | ||
| ``` | ||
|
|
||
| ### uuid.v7([options[, buffer[, offset]]]) | ||
|
|
||
| Create an RFC version 7 (random) UUID | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.