-
-
Notifications
You must be signed in to change notification settings - Fork 1k
feat(string): support uuid v7 #3701
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
base: next
Are you sure you want to change the base?
Conversation
The implementation "signature" is not a real signature exposed to typescript if multiple signatures exist. Because of that, the documentation is just clutter that might fall out of date.
✅ Deploy Preview for fakerjs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## next #3701 +/- ##
==========================================
- Coverage 99.97% 99.97% -0.01%
==========================================
Files 2995 2996 +1
Lines 236323 236245 -78
Branches 941 950 +9
==========================================
- Hits 236266 236187 -79
- Misses 57 58 +1
🚀 New features to boost your workflow:
|
Co-authored-by: Shinigami <chrissi92@hotmail.de>
matthewmayer
left a comment
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.
should we also mention this as one of the methods listed in
https://fakerjs.dev/guide/usage#reproducible-results
Co-authored-by: Matt Mayer <152770+matthewmayer@users.noreply.github.com>
I don't think this is necessary, since these are only examples and not a comprehensible list. Or did you mean to replace one of the examples from the date module with this method, to get more diversity in the examples? |
Yeah good idea |
src/modules/string/index.ts
Outdated
| version?: 4 | 7; | ||
| /** | ||
| * The timestamp to encode into the UUID. | ||
| * This parameter is only relevant for time based UUID's. |
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.
This one needs a fix too for consistency.
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.
You are right. You gave me a suggestion block and I took the easy way of simply committing it inside of GH without looking around first. I'll do better next time. :)
Description
This PR solves #3699.
The PR introduces support for generating UUID v7 values via
faker.string.uuid({ version: 7 }). This extends the existing function with a time ordered variant based on the Unix timestamp. To preserve the current behavior, an explicit signature forfaker.string.uuid({ version: 4 })(the default) has also been added.Since UUID v7 is time‑based, the new API allows providing a reference date (
refDate) argument as well.A few implementation choices differ slightly from the usual patterns in this project:
refDateargument and the selected version clearer. Another benefit is that the default signature can retain its originalsincetag (v8.0.0).For documentation generation to work correctly, an additional signature mirroring the implementation is required, and this one must appear last. You can verify this in the documentation preview for this PR.
Link