+7
-3
@@ -64,5 +64,9 @@ import rng from './rng.js'; | ||
| clockseq ??= ((rnds[8] << 8) | rnds[9]) & 0x3fff; | ||
| node ??= rnds.slice(10, 16); | ||
| if (node == null) { | ||
| node = rnds.slice(10, 16); | ||
| node[0] |= 0x01; | ||
| } | ||
| msecs += 12219292800000; | ||
| const tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000; | ||
| const t = (msecs & 0xfffffff) * 10000 + nsecs; | ||
| const tl = t >>> 0; | ||
| buf[offset++] = (tl >>> 24) & 0xff; | ||
@@ -72,3 +76,3 @@ buf[offset++] = (tl >>> 16) & 0xff; | ||
| buf[offset++] = tl & 0xff; | ||
| const tmh = ((msecs / 0x100000000) * 10000) & 0xfffffff; | ||
| const tmh = (((msecs / 0x10000000) | 0) * 625 + ((t / 0x100000000) | 0)) & 0xfffffff; | ||
| buf[offset++] = (tmh >>> 8) & 0xff; | ||
@@ -75,0 +79,0 @@ buf[offset++] = tmh & 0xff; |
+5
-2
@@ -21,3 +21,3 @@ import rng from './rng.js'; | ||
| if (now > state.msecs) { | ||
| state.seq = (rnds[6] << 23) | (rnds[7] << 16) | (rnds[8] << 8) | rnds[9]; | ||
| state.seq = v7Sequence(rnds); | ||
| state.msecs = now; | ||
@@ -47,3 +47,3 @@ } | ||
| msecs ??= Date.now(); | ||
| seq ??= ((rnds[6] * 0x7f) << 24) | (rnds[7] << 16) | (rnds[8] << 8) | rnds[9]; | ||
| seq ??= v7Sequence(rnds); | ||
| buf[offset++] = (msecs / 0x10000000000) & 0xff; | ||
@@ -67,2 +67,5 @@ buf[offset++] = (msecs / 0x100000000) & 0xff; | ||
| } | ||
| function v7Sequence(rnds) { | ||
| return ((rnds[6] & 0x7f) << 24) | (rnds[7] << 16) | (rnds[8] << 8) | rnds[9]; | ||
| } | ||
| export default v7; |
+7
-3
@@ -64,5 +64,9 @@ import rng from './rng.js'; | ||
| clockseq ??= ((rnds[8] << 8) | rnds[9]) & 0x3fff; | ||
| node ??= rnds.slice(10, 16); | ||
| if (node == null) { | ||
| node = rnds.slice(10, 16); | ||
| node[0] |= 0x01; | ||
| } | ||
| msecs += 12219292800000; | ||
| const tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000; | ||
| const t = (msecs & 0xfffffff) * 10000 + nsecs; | ||
| const tl = t >>> 0; | ||
| buf[offset++] = (tl >>> 24) & 0xff; | ||
@@ -72,3 +76,3 @@ buf[offset++] = (tl >>> 16) & 0xff; | ||
| buf[offset++] = tl & 0xff; | ||
| const tmh = ((msecs / 0x100000000) * 10000) & 0xfffffff; | ||
| const tmh = (((msecs / 0x10000000) | 0) * 625 + ((t / 0x100000000) | 0)) & 0xfffffff; | ||
| buf[offset++] = (tmh >>> 8) & 0xff; | ||
@@ -75,0 +79,0 @@ buf[offset++] = tmh & 0xff; |
+5
-2
@@ -21,3 +21,3 @@ import rng from './rng.js'; | ||
| if (now > state.msecs) { | ||
| state.seq = (rnds[6] << 23) | (rnds[7] << 16) | (rnds[8] << 8) | rnds[9]; | ||
| state.seq = v7Sequence(rnds); | ||
| state.msecs = now; | ||
@@ -47,3 +47,3 @@ } | ||
| msecs ??= Date.now(); | ||
| seq ??= ((rnds[6] * 0x7f) << 24) | (rnds[7] << 16) | (rnds[8] << 8) | rnds[9]; | ||
| seq ??= v7Sequence(rnds); | ||
| buf[offset++] = (msecs / 0x10000000000) & 0xff; | ||
@@ -67,2 +67,5 @@ buf[offset++] = (msecs / 0x100000000) & 0xff; | ||
| } | ||
| function v7Sequence(rnds) { | ||
| return ((rnds[6] & 0x7f) << 24) | (rnds[7] << 16) | (rnds[8] << 8) | rnds[9]; | ||
| } | ||
| export default v7; |
+4
-3
| { | ||
| "name": "uuid", | ||
| "version": "14.0.1", | ||
| "version": "14.0.2", | ||
| "description": "RFC9562 UUIDs", | ||
@@ -55,2 +55,3 @@ "type": "module", | ||
| "prettier": "3.8.3", | ||
| "publint": "0.3.21", | ||
| "release-please": "17.3.0", | ||
@@ -82,2 +83,4 @@ "runmd": "2.1.1", | ||
| "examples:node:typescript:test": "cd examples/typescript && npm test", | ||
| "format": "biome format --write .", | ||
| "format:check": "biome format --check .", | ||
| "lint": "npm run biome:check", | ||
@@ -92,4 +95,2 @@ "md": "runmd --watch --output=README.md README_js.md", | ||
| "pretest": "npm run build", | ||
| "format": "biome format --write .", | ||
| "format:check": "biome format --check .", | ||
| "release": "standard-version --no-verify", | ||
@@ -96,0 +97,0 @@ "test:benchmark": "cd examples/benchmark && npm test", |
+19
-19
@@ -44,19 +44,19 @@ <!-- | ||
| | | | | | ||
| | --- | --- | --- | | ||
| | [`uuid.NIL`](#uuidnil) | The nil UUID string (all zeros) | New in `uuid@8.3` | | ||
| | [`uuid.MAX`](#uuidmax) | The max UUID string (all ones) | New in `uuid@9.1` | | ||
| | [`uuid.parse()`](#uuidparsestr) | Convert UUID string to array of bytes | New in `uuid@8.3` | | ||
| | [`uuid.stringify()`](#uuidstringifyarr-offset) | Convert array of bytes to UUID string | New in `uuid@8.3` | | ||
| | [`uuid.v1()`](#uuidv1options-buffer-offset) | Create a version 1 (timestamp) UUID | | | ||
| | [`uuid.v1ToV6()`](#uuidv1tov6uuid) | 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.v6()`](#uuidv6options-buffer-offset) | Create a version 6 (timestamp, reordered) UUID | New in `uuid@10` | | ||
| | [`uuid.v6ToV1()`](#uuidv6tov1uuid) | 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.v8()`](#uuidv8)~~ | "Intentionally left blank" | | | ||
| | [`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` | | ||
| | | | | ||
| | --- | --- | | ||
| | [`uuid.NIL`](#uuidnil) | The nil UUID string (all zeros) | | ||
| | [`uuid.MAX`](#uuidmax) | The max UUID string (all ones) | | ||
| | [`uuid.parse()`](#uuidparsestr) | Convert UUID string to array of bytes | | ||
| | [`uuid.stringify()`](#uuidstringifyarr-offset) | Convert array of bytes to UUID string | | ||
| | [`uuid.v1()`](#uuidv1options-buffer-offset) | Generate a version 1 (timestamp) UUID | | ||
| | [`uuid.v1ToV6()`](#uuidv1tov6uuid) | Convert a version 1 UUID to version 6 | | ||
| | [`uuid.v3()`](#uuidv3name-namespace-buffer-offset) | Generate a version 3 (namespace w/ MD5) UUID | | ||
| | [`uuid.v4()`](#uuidv4options-buffer-offset) | Generate a version 4 (random) UUID | | ||
| | [`uuid.v5()`](#uuidv5name-namespace-buffer-offset) | Generate a version 5 (namespace w/ SHA-1) UUID | | ||
| | [`uuid.v6()`](#uuidv6options-buffer-offset) | Generate a version 6 (timestamp, reordered) UUID | | ||
| | [`uuid.v6ToV1()`](#uuidv6tov1uuid) | Convert a version 6 UUID to version 1 | | ||
| | [`uuid.v7()`](#uuidv7options-buffer-offset) | Generate a version 7 (Unix Epoch time-based) UUID | | ||
| | ~~[`uuid.v8()`](#uuidv8)~~ | "Intentionally left blank" | | ||
| | [`uuid.validate()`](#uuidvalidatestr) | Test a string to see if it is a valid UUID | | ||
| | [`uuid.version()`](#uuidversionstr) | Detect RFC version of a UUID | | ||
@@ -361,3 +361,3 @@ ## API | ||
| uuidv7(); // ⇨ '01941f29-7c00-75f4-a310-744d2167fc5b' | ||
| uuidv7(); // ⇨ '01941f29-7c00-73e4-a310-744d2167fc5b' | ||
| ``` | ||
@@ -469,3 +469,3 @@ | ||
| **Node**: `uuid` [builds are tested](https://github.com/uuidjs/uuid/blob/main/.github/workflows/ci.yml#L26-L27) against node ([LTS releases](https://github.com/nodejs/Release)), plus one prior. E.g. At the time of this writing `node@20` is the "maintenance" release and `node@24` is the "current" release, so `uuid` supports `node@20`-`node@24`. | ||
| **Node**: `uuid` [builds are tested](https://github.com/uuidjs/uuid/blob/main/.github/workflows/ci.yml#L31) against node ([LTS releases](https://github.com/nodejs/Release)), plus one prior. E.g. At the time of this writing `node@20` is the "maintenance" release and `node@24` is the "current" release, so `uuid` supports `node@20`-`node@24`. | ||
@@ -472,0 +472,0 @@ **Typescript**: TS versions released within the past two years are supported. [source](https://github.com/microsoft/TypeScript/issues/49088#issuecomment-2468723715) |
65685
0.02%1210
1.17%17
6.25%