-
-
Notifications
You must be signed in to change notification settings - Fork 879
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
uuid v7 #681
Open
pmccarren
wants to merge
19
commits into
uuidjs:rfc4122bis
Choose a base branch
from
pmccarren:uuid7
base: rfc4122bis
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+540
−11
Open
uuid v7 #681
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
0b8f680
feat: implement uuid7 (#580)
pmccarren a112083
fix: add v7.js to .local (#580)
pmccarren 5a89a92
fix: add v7 to uuid-bin
pmccarren 92bc63a
chore: fix readme anchor
pmccarren ba6d9cc
chore: use generated readme, remove timestamp arg from uuid-bin v7
pmccarren 3a201c3
fix: typo in uuid regex, add negative test cases
pmccarren b710c41
fix: do not mutate provided rnds, add v7 unit tests
pmccarren 1a61942
fix: validation test should not pass version 0
pmccarren bf11212
chore: update package.json description
pmccarren a17479a
Update src/v7.js
pmccarren ced5fdc
include uuid v6 and v8 in validation regex
pmccarren 7264c2c
chore: add test:matching script to package.json
pmccarren 2263096
fix: v7 monotonicity and lexicographical sorting
pmccarren 4022ec2
refactor: v7 seq reinitialization
pmccarren 1d5c88a
chore: update v7 README
pmccarren aef75d7
docs: add note about `cypto.randomUUID()` (#686)
jonkoops 2626fe2
Merge branch 'uuidjs:main' into uuid7
pmccarren 3cb9acd
chore: fix README_js.md prettier
pmccarren 7f1ceaf
chore: render README.md
pmccarren File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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 @@ | ||
../../v7.js |
This file contains 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 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 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 | ||||
---|---|---|---|---|---|---|
|
@@ -21,7 +21,7 @@ require('crypto').randomUUID = undefined; | |||||
|
||||||
For the creation of [RFC4122](https://www.ietf.org/rfc/rfc4122.txt) UUIDs | ||||||
|
||||||
- **Complete** - Support for RFC4122 version 1, 3, 4, and 5 UUIDs | ||||||
- **Complete** - Support for RFC4122 version 1, 3, 4, 5, and 7 UUIDs | ||||||
- **Cross-platform** - Support for ... | ||||||
- CommonJS, [ECMAScript Modules](#ecmascript-modules) and [CDN builds](#cdn-builds) | ||||||
- Node 12, 14, 16, 18 | ||||||
|
@@ -32,7 +32,9 @@ For the creation of [RFC4122](https://www.ietf.org/rfc/rfc4122.txt) UUIDs | |||||
- **Small** - Zero-dependency, small footprint, plays nice with "tree shaking" packagers | ||||||
- **CLI** - Includes the [`uuid` command line](#command-line) utility | ||||||
|
||||||
**Upgrading from `uuid@3`?** Your code is probably okay, but check out [Upgrading From `uuid@3`](#upgrading-from-uuid3) for details. | ||||||
> **Note** Upgrading from `uuid@3`? Your code is probably okay, but check out [Upgrading From `uuid@3`](#upgrading-from-uuid3) for details. | ||||||
> **Note** Only interested in creating a version 4 UUID? You might be able to use [`cypto.randomUUID()`](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID), eliminating the need to install this library. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another small typo here
Suggested change
|
||||||
## Quickstart | ||||||
|
||||||
|
@@ -71,6 +73,7 @@ For timestamp UUIDs, namespace UUIDs, and other options read on ... | |||||
| [`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.validate()`](#uuidvalidatestr) | Test a string to see if it is a valid UUID | New in `uuid@8.3` | | ||||||
| [`uuid.version()`](#uuidversionstr) | Detect RFC version of a UUID | New in `uuid@8.3` | | ||||||
|
||||||
|
@@ -257,6 +260,29 @@ import { v5 as uuidv5 } from 'uuid'; | |||||
uuidv5('https://www.w3.org/', uuidv5.URL); // RESULT | ||||||
``` | ||||||
|
||||||
### uuid.v7([options[, buffer[, offset]]]) | ||||||
|
||||||
Create an RFC version 7 (random) UUID | ||||||
|
||||||
| | | | ||||||
| --- | --- | | ||||||
| [`options`] | `Object` with one or more of the following properties: | | ||||||
| [`options.msecs`] | RFC "timestamp" field (`Number` of milliseconds, unix epoch) | | ||||||
| [`options.random`] | `Array` of 16 random bytes (0-255) | | ||||||
| [`options.rng`] | Alternative to `options.random`, a `Function` that returns an `Array` of 16 random bytes (0-255) | | ||||||
| [`options.seq`] | 31 bit monotonic sequence counter as `Number` between 0 - 0x7fffffff | | ||||||
| [`buffer`] | `Array \| Buffer` If specified, uuid will be written here in byte-form, starting at `offset` | | ||||||
| [`offset` = 0] | `Number` Index to start writing UUID bytes in `buffer` | | ||||||
| _returns_ | UUID `String` if no `buffer` is specified, otherwise returns `buffer` | | ||||||
|
||||||
Example: | ||||||
|
||||||
```javascript --run | ||||||
import { v7 as uuidv7 } from 'uuid'; | ||||||
|
||||||
uuidv7(); // RESULT | ||||||
``` | ||||||
|
||||||
### uuid.validate(str) | ||||||
|
||||||
Test a string to see if it is a valid UUID | ||||||
|
@@ -331,6 +357,7 @@ Usage: | |||||
uuid v3 <name> <namespace uuid> | ||||||
uuid v4 | ||||||
uuid v5 <name> <namespace uuid> | ||||||
uuid v7 | ||||||
uuid --help | ||||||
|
||||||
Note: <namespace uuid> may be "URL" or "DNS" to use the corresponding UUIDs | ||||||
|
This file contains 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 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 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 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 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 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,12 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<title>UUID esmodule webpack example</title> | ||
</head> | ||
|
||
<body> | ||
<script type="text/javascript" src="./dist/v7.js"></script> | ||
</body> | ||
|
||
</html> |
This file contains 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,8 @@ | ||
import { v7 as uuidv7 } from 'uuid'; | ||
|
||
import testpage from '../utils/testpage'; | ||
|
||
testpage(function (addTest, done) { | ||
addTest('uuidv7()', uuidv7()); | ||
done(); | ||
}); |
This file contains 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 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 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,3 @@ | ||
import { v7 as uuidv7 } from 'uuid'; | ||
|
||
uuidv7(); |
This file contains 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 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 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,12 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<title>UUID esmodule webpack example</title> | ||
</head> | ||
|
||
<body> | ||
<script type="text/javascript" src="./dist/v7.js"></script> | ||
</body> | ||
|
||
</html> |
This file contains 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,9 @@ | ||
import { v7 as uuidv7 } from 'uuid'; | ||
|
||
import testpage from '../utils/testpage'; | ||
|
||
testpage(function (addTest, done) { | ||
addTest('uuidv7()', uuidv7()); | ||
|
||
done(); | ||
}); |
This file contains 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 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,3 @@ | ||
import { v7 as uuidv7 } from 'uuid'; | ||
|
||
uuidv7(); |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a small typo here