-
-
Notifications
You must be signed in to change notification settings - Fork 938
Closed
Labels
Description
In uuid.v7
, when the msecs
option is specified without the seq
option, the timestamp becomes nil despite being a value greater than 0. Is this intentional behavior? From what I can see in the implementation, it appears that uuid.v7
tries to manage the monotonic sequence counter unless it is specified as an option.
Example:
import { v7 as uuidv7 } from "uuid";
const msecs = new Date("2024-06-12").getTime();
console.log(msecs);
// Print:
// 1718150400000
console.log(uuidv7({ msecs }));
// Print:
// 00000000-0000-7dd6-bd36-038a8af1a5f1
// ^^^^^^^^ ^^^^ ^ <- In this script, the is fixed.
// ^^^ ^^^^ ^^^^^^^^^^^^ <- Changes with each execution.
console.log(uuidv7({ msecs, seq: 0 }));
// Print:
// 019009be-8800-7000-8000-061f2f366242
// ^^^^^^^^ ^^^^ ^^^^ ^^^^ ^ <- In this script, the is fixed.
// ^^^^^^^^^^^ <- Changes with each execution.
console.log(parseInt("019009be" + "8800", 16));
// Print:
// 1718150400000 <- This is the same as the value of msecs.
Addition 2 days after issue creation:
Since the bug label was added, I am updating the information based on the ISSUE_TEMPLATE.
- I have searched the existing issues
- I am not using version 13.x of node (if so, please upgrade)
Description of the problem
Please refer to the above.
Recipe for reproducing
Please refer to the "Example:" above.
Additional information
N/A
Environment
System:
OS: Linux 6.5 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish)
CPU: (24) x64 12th Gen Intel(R) Core(TM) i9-12900K
Memory: 25.67 GB / 31.11 GB
Container: Yes
Shell: 5.1.16 - /bin/bash
Binaries:
Node: 22.2.0 - ~/.volta/tools/image/node/22.2.0/bin/node
npm: 10.7.0 - ~/.volta/tools/image/node/22.2.0/bin/npm
Browsers:
Chromium: 125.0.6422.141
npmPackages:
@tsconfig/strictest: ^2.0.5 => 2.0.5
@types/node: ^20.14.2 => 20.14.2
@types/unzipper: ^0.10.9 => 0.10.9
dprint: ^0.46.2 => 0.46.2
esbuild: ^0.21.4 => 0.21.4
is-plain-obj: ^4.1.0 => 4.1.0
tar: ^7.2.0 => 7.2.0
type-fest: ^4.20.0 => 4.20.0
typescript: ^5.4.5 => 5.4.5
unzipper: ^0.12.1 => 0.12.1
uuid: ^10.0.0 => 10.0.0