uuid 13.0.2 → 14.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -34,7 +34,7 @@ npm install uuid
34
34
  ```javascript
35
35
  import { v4 as uuidv4 } from 'uuid';
36
36
 
37
- uuidv4(); // ⇨ '9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d'
37
+ uuidv4(); // ⇨ 'b18794e8-5d0d-417c-b361-ba38e78411b4'
38
38
  ```
39
39
 
40
40
  For timestamp UUIDs, namespace UUIDs, and other options read on ...
@@ -174,20 +174,12 @@ Create an RFC version 1 (timestamp) UUID
174
174
  | _returns_ | UUID `String` if no `buffer` is specified, otherwise returns `buffer` |
175
175
  | _throws_ | `Error` if more than 10M UUIDs/sec are requested |
176
176
 
177
- <!-- prettier-ignore -->
178
- > [!NOTE]
179
- > The default [node id](https://datatracker.ietf.org/doc/html/rfc9562#section-5.1) (the last 12 digits in the UUID) is generated once, randomly, on process startup, and then remains unchanged for the duration of the process.
180
-
181
- <!-- prettier-ignore -->
182
- > [!NOTE]
183
- > `options.random` and `options.rng` are only meaningful on the very first call to `v1()`, where they may be passed to initialize the internal `node` and `clockseq` fields.
184
-
185
177
  Example:
186
178
 
187
179
  ```javascript
188
180
  import { v1 as uuidv1 } from 'uuid';
189
181
 
190
- uuidv1(); // ⇨ '2c5ea4c0-4067-11e9-9b5d-ab8dfbbd4bed'
182
+ uuidv1(); // ⇨ '57fd0000-c7d3-11ef-841d-514d2167fc5b'
191
183
  ```
192
184
 
193
185
  Example using `options`:
@@ -242,7 +234,7 @@ Example:
242
234
  ```javascript
243
235
  import { v4 as uuidv4 } from 'uuid';
244
236
 
245
- uuidv4(); // ⇨ '1b9d6bcd-bbfd-4b2d-9b5d-ab8dfbbd4bed'
237
+ uuidv4(); // ⇨ 'b18794e8-5d0d-417c-b361-ba38e78411b4'
246
238
  ```
247
239
 
248
240
  Example using predefined `random` values:
@@ -318,7 +310,7 @@ This method takes the same arguments as uuid.v1().
318
310
  ```javascript
319
311
  import { v6 as uuidv6 } from 'uuid';
320
312
 
321
- uuidv6(); // ⇨ '1e940672-c5ea-64c1-9bdd-2b0d7b3dcb6d'
313
+ uuidv6(); // ⇨ '1efc7d35-7fd0-6000-841d-504d2167fc5b'
322
314
  ```
323
315
 
324
316
  Example using `options`:
@@ -365,7 +357,7 @@ Example:
365
357
  ```javascript
366
358
  import { v7 as uuidv7 } from 'uuid';
367
359
 
368
- uuidv7(); // ⇨ '01695553-c90c-745a-b76f-770d7b3dcb6d'
360
+ uuidv7(); // ⇨ '01941f29-7c00-75f4-a310-744d2167fc5b'
369
361
  ```
370
362
 
371
363
  ### ~~uuid.v8()~~
@@ -472,13 +464,13 @@ Prior to `uuid@11`, it was possible for `options` state to interfere with the in
472
464
 
473
465
  **Browsers**: `uuid` [builds are tested](/uuidjs/uuid/blob/main/wdio.conf.js) against the latest version of desktop Chrome, Safari, Firefox, and Edge. Mobile versions of these same browsers are expected to work but aren't currently tested.
474
466
 
475
- **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@18`-`node@24`.
467
+ **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`.
476
468
 
477
469
  **Typescript**: TS versions released within the past two years are supported. [source](https://github.com/microsoft/TypeScript/issues/49088#issuecomment-2468723715)
478
470
 
479
471
  ## Known issues
480
472
 
481
- <!-- This header is referenced as an anchor in src/rng-browser.ts -->
473
+ <!-- This header is referenced as an anchor in src/rng.ts -->
482
474
 
483
475
  ### "getRandomValues() not supported"
484
476
 
@@ -496,4 +488,4 @@ import { v4 as uuidv4 } from 'uuid';
496
488
 
497
489
  ---
498
490
 
499
- Markdown generated from [README_js.md](README_js.md) by <a href="https://github.com/broofa/runmd"><image height="13" src="https://camo.githubusercontent.com/5c7c603cd1e6a43370b0a5063d457e0dabb74cf317adc7baba183acb686ee8d0/687474703a2f2f692e696d6775722e636f6d2f634a4b6f3662552e706e67" /></a>
491
+ Generated from [README_js.md](README_js.md) by [`runmd`](https://github.com/broofa/runmd)
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- export type * from './types.js';
2
1
  export { default as MAX } from './max.js';
3
2
  export { default as NIL } from './nil.js';
4
3
  export { default as parse } from './parse.js';
5
4
  export { default as stringify } from './stringify.js';
5
+ export type * from './types.js';
6
6
  export { default as v1 } from './v1.js';
7
7
  export { default as v1ToV6 } from './v1ToV6.js';
8
8
  export { default as v3 } from './v3.js';
package/dist/md5.js CHANGED
@@ -16,7 +16,7 @@ function getOutputLength(inputLength8) {
16
16
  function wordsToMd5(x, len) {
17
17
  const xpad = new Uint32Array(getOutputLength(len)).fill(0);
18
18
  xpad.set(x);
19
- xpad[len >> 5] |= 0x80 << len % 32;
19
+ xpad[len >> 5] |= 0x80 << (len % 32);
20
20
  xpad[xpad.length - 1] = len;
21
21
  x = xpad;
22
22
  let a = 1732584193;
package/dist/parse.d.ts CHANGED
@@ -1,2 +1,3 @@
1
- declare function parse(uuid: string): Uint8Array;
1
+ import type { NonSharedArrayBuffer } from './types.js';
2
+ declare function parse(uuid: string): NonSharedArrayBuffer;
2
3
  export default parse;
package/dist/rng.js CHANGED
@@ -1,11 +1,4 @@
1
- let getRandomValues;
2
1
  const rnds8 = new Uint8Array(16);
3
2
  export default function rng() {
4
- if (!getRandomValues) {
5
- if (typeof crypto === 'undefined' || !crypto.getRandomValues) {
6
- throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
7
- }
8
- getRandomValues = crypto.getRandomValues.bind(crypto);
9
- }
10
- return getRandomValues(rnds8);
3
+ return crypto.getRandomValues(rnds8);
11
4
  }
package/dist/sha1.js CHANGED
@@ -34,7 +34,7 @@ function sha1(bytes) {
34
34
  }
35
35
  M[i] = arr;
36
36
  }
37
- M[N - 1][14] = ((bytes.length - 1) * 8) / Math.pow(2, 32);
37
+ M[N - 1][14] = ((bytes.length - 1) * 8) / 2 ** 32;
38
38
  M[N - 1][14] = Math.floor(M[N - 1][14]);
39
39
  M[N - 1][15] = ((bytes.length - 1) * 8) & 0xffffffff;
40
40
  for (let i = 0; i < N; ++i) {
package/dist/types.d.ts CHANGED
@@ -19,3 +19,4 @@ export type Version7Options = {
19
19
  seq?: number;
20
20
  rng?: () => Uint8Array;
21
21
  };
22
+ export type NonSharedArrayBuffer = ReturnType<typeof Uint8Array.of>;
package/dist/v1.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Version1Options } from './types.js';
1
+ import type { Version1Options } from './types.js';
2
2
  type V1State = {
3
3
  node?: Uint8Array;
4
4
  clockseq?: number;
package/dist/v1ToV6.d.ts CHANGED
@@ -1,2 +1,3 @@
1
+ import type { NonSharedArrayBuffer } from './types.js';
1
2
  export default function v1ToV6(uuid: string): string;
2
- export default function v1ToV6(uuid: Uint8Array): Uint8Array;
3
+ export default function v1ToV6(uuid: Uint8Array): NonSharedArrayBuffer;
package/dist/v3.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { UUIDTypes } from './types.js';
1
+ import type { UUIDTypes } from './types.js';
2
2
  export { DNS, URL } from './v35.js';
3
3
  declare function v3(value: string | Uint8Array, namespace: UUIDTypes, buf?: undefined, offset?: number): string;
4
4
  declare function v3<TBuf extends Uint8Array = Uint8Array>(value: string | Uint8Array, namespace: UUIDTypes, buf: TBuf, offset?: number): TBuf;
package/dist/v35.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { UUIDTypes } from './types.js';
1
+ import type { UUIDTypes } from './types.js';
2
2
  export declare function stringToBytes(str: string): Uint8Array;
3
3
  export declare const DNS = "6ba7b810-9dad-11d1-80b4-00c04fd430c8";
4
4
  export declare const URL = "6ba7b811-9dad-11d1-80b4-00c04fd430c8";
package/dist/v35.js CHANGED
@@ -26,7 +26,7 @@ export default function v35(version, hash, value, namespace, buf, offset) {
26
26
  bytes[6] = (bytes[6] & 0x0f) | version;
27
27
  bytes[8] = (bytes[8] & 0x3f) | 0x80;
28
28
  if (buf) {
29
- offset = offset || 0;
29
+ offset ??= 0;
30
30
  if (offset < 0 || offset + 16 > buf.length) {
31
31
  throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
32
32
  }
package/dist/v4.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Version4Options } from './types.js';
1
+ import type { Version4Options } from './types.js';
2
2
  declare function v4(options?: Version4Options, buf?: undefined, offset?: number): string;
3
3
  declare function v4<TBuf extends Uint8Array = Uint8Array>(options: Version4Options | undefined, buf: TBuf, offset?: number): TBuf;
4
4
  export default v4;
package/dist/v4.js CHANGED
@@ -1,6 +1,11 @@
1
- import native from './native.js';
2
1
  import rng from './rng.js';
3
2
  import { unsafeStringify } from './stringify.js';
3
+ function v4(options, buf, offset) {
4
+ if (!buf && !options && crypto.randomUUID) {
5
+ return crypto.randomUUID();
6
+ }
7
+ return _v4(options, buf, offset);
8
+ }
4
9
  function _v4(options, buf, offset) {
5
10
  options = options || {};
6
11
  const rnds = options.random ?? options.rng?.() ?? rng();
@@ -21,10 +26,4 @@ function _v4(options, buf, offset) {
21
26
  }
22
27
  return unsafeStringify(rnds);
23
28
  }
24
- function v4(options, buf, offset) {
25
- if (native.randomUUID && !buf && !options) {
26
- return native.randomUUID();
27
- }
28
- return _v4(options, buf, offset);
29
- }
30
29
  export default v4;
package/dist/v5.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { UUIDTypes } from './types.js';
1
+ import type { UUIDTypes } from './types.js';
2
2
  export { DNS, URL } from './v35.js';
3
3
  declare function v5(value: string | Uint8Array, namespace: UUIDTypes, buf?: undefined, offset?: number): string;
4
4
  declare function v5<TBuf extends Uint8Array = Uint8Array>(value: string | Uint8Array, namespace: UUIDTypes, buf: TBuf, offset?: number): TBuf;
package/dist/v6.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Version6Options } from './types.js';
1
+ import type { Version6Options } from './types.js';
2
2
  declare function v6(options?: Version6Options, buf?: undefined, offset?: number): string;
3
3
  declare function v6<TBuf extends Uint8Array = Uint8Array>(options: Version6Options | undefined, buf: TBuf, offset?: number): TBuf;
4
4
  export default v6;
package/dist/v7.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Version7Options } from './types.js';
1
+ import type { Version7Options } from './types.js';
2
2
  type V7State = {
3
3
  msecs?: number;
4
4
  seq?: number;
package/dist-node/rng.js CHANGED
@@ -1,10 +1,4 @@
1
- import { randomFillSync } from 'node:crypto';
2
- const rnds8Pool = new Uint8Array(256);
3
- let poolPtr = rnds8Pool.length;
1
+ const rnds8 = new Uint8Array(16);
4
2
  export default function rng() {
5
- if (poolPtr > rnds8Pool.length - 16) {
6
- randomFillSync(rnds8Pool);
7
- poolPtr = 0;
8
- }
9
- return rnds8Pool.slice(poolPtr, (poolPtr += 16));
3
+ return crypto.getRandomValues(rnds8);
10
4
  }
package/dist-node/v35.js CHANGED
@@ -26,7 +26,7 @@ export default function v35(version, hash, value, namespace, buf, offset) {
26
26
  bytes[6] = (bytes[6] & 0x0f) | version;
27
27
  bytes[8] = (bytes[8] & 0x3f) | 0x80;
28
28
  if (buf) {
29
- offset = offset || 0;
29
+ offset ??= 0;
30
30
  if (offset < 0 || offset + 16 > buf.length) {
31
31
  throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
32
32
  }
package/dist-node/v4.js CHANGED
@@ -1,6 +1,11 @@
1
- import native from './native.js';
2
1
  import rng from './rng.js';
3
2
  import { unsafeStringify } from './stringify.js';
3
+ function v4(options, buf, offset) {
4
+ if (!buf && !options && crypto.randomUUID) {
5
+ return crypto.randomUUID();
6
+ }
7
+ return _v4(options, buf, offset);
8
+ }
4
9
  function _v4(options, buf, offset) {
5
10
  options = options || {};
6
11
  const rnds = options.random ?? options.rng?.() ?? rng();
@@ -21,10 +26,4 @@ function _v4(options, buf, offset) {
21
26
  }
22
27
  return unsafeStringify(rnds);
23
28
  }
24
- function v4(options, buf, offset) {
25
- if (native.randomUUID && !buf && !options) {
26
- return native.randomUUID();
27
- }
28
- return _v4(options, buf, offset);
29
- }
30
29
  export default v4;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uuid",
3
- "version": "13.0.2",
3
+ "version": "14.0.1",
4
4
  "description": "RFC9562 UUIDs",
5
5
  "type": "module",
6
6
  "funding": [
@@ -26,7 +26,10 @@
26
26
  "types": "./dist/index.d.ts",
27
27
  "exports": {
28
28
  ".": {
29
- "node": "./dist-node/index.js",
29
+ "node": {
30
+ "types": "./dist/index.d.ts",
31
+ "default": "./dist-node/index.js"
32
+ },
30
33
  "default": "./dist/index.js"
31
34
  },
32
35
  "./package.json": "./package.json"
@@ -37,60 +40,55 @@
37
40
  "!**/test"
38
41
  ],
39
42
  "devDependencies": {
40
- "@babel/eslint-parser": "7.27.1",
41
- "@commitlint/cli": "19.8.0",
42
- "@commitlint/config-conventional": "19.8.0",
43
- "@eslint/js": "9.26.0",
43
+ "@biomejs/biome": "2.4.10",
44
+ "@commitlint/cli": "20.5.0",
45
+ "@commitlint/config-conventional": "20.5.0",
44
46
  "bundlewatch": "0.4.1",
45
- "commander": "13.1.0",
46
- "eslint": "9.26.0",
47
- "eslint-config-prettier": "10.1.2",
48
- "eslint-plugin-prettier": "5.4.0",
49
- "globals": "16.0.0",
50
- "husky": "9.1.7",
51
- "jest": "29.7.0",
52
- "lint-staged": "15.5.2",
53
- "neostandard": "0.12.1",
54
- "npm-run-all": "4.1.5",
55
- "prettier": "3.5.3",
56
- "release-please": "17.0.0",
57
- "runmd": "1.4.1",
47
+ "commander": "14.0.3",
48
+ "globals": "17.4.0",
49
+ "jest": "30.3.0",
50
+ "lefthook": "1.11.13",
51
+ "lint-staged": "16.4.0",
52
+ "neostandard": "0.13.0",
53
+ "npm-run-all2": "8.0.4",
54
+ "prettier": "3.8.3",
55
+ "release-please": "17.3.0",
56
+ "runmd": "2.1.1",
58
57
  "standard-version": "9.5.0",
59
- "typescript": "5.2.2",
60
- "typescript-eslint": "8.32.0"
58
+ "typescript": "5.4.3"
61
59
  },
62
60
  "optionalDevDependencies": {
63
- "@wdio/browserstack-service": "9.2.1",
64
- "@wdio/cli": "9.2.1",
65
- "@wdio/jasmine-framework": "9.2.1",
66
- "@wdio/local-runner": "9.2.1",
67
- "@wdio/spec-reporter": "9.1.3",
68
- "@wdio/static-server-service": "9.1.3"
61
+ "@wdio/browserstack-service": "9.27.0",
62
+ "@wdio/cli": "9.27.0",
63
+ "@wdio/jasmine-framework": "9.27.0",
64
+ "@wdio/local-runner": "9.27.0",
65
+ "@wdio/spec-reporter": "9.27.0",
66
+ "@wdio/static-server-service": "9.27.0"
69
67
  },
70
68
  "scripts": {
71
69
  "build": "./scripts/build.sh",
72
70
  "build:watch": "tsc --watch -p tsconfig.json",
73
71
  "bundlewatch": "npm run pretest:browser && bundlewatch --config bundlewatch.config.json",
74
- "docs:diff": "npm run docs && git diff --quiet -I \"[0-9a-f-]{36}\" README.md",
72
+ "docs:diff": "npm run docs && git diff README.md",
75
73
  "docs": "npm run build && npx runmd --output=README.md README_js.md",
76
- "eslint:check": "eslint src/ test/ examples/ *.[jt]s",
77
- "eslint:fix": "eslint --fix src/ test/ examples/ *.[jt]s",
74
+ "biome:check": "biome check .",
75
+ "biome:fix": "biome check --write .",
78
76
  "examples:browser:rollup:build": "cd examples/browser-rollup && npm run build",
79
77
  "examples:browser:webpack:build": "cd examples/browser-webpack && npm run build",
80
78
  "examples:node:esmodules:test": "cd examples/node-esmodules && npm test",
81
79
  "examples:node:jest:test": "cd examples/node-jest && npm test",
82
80
  "examples:node:typescript:test": "cd examples/typescript && npm test",
83
- "lint": "npm run eslint:check && npm run prettier:check",
81
+ "lint": "npm run biome:check",
84
82
  "md": "runmd --watch --output=README.md README_js.md",
85
83
  "prepack": "npm run build -- --no-pack",
86
- "prepare": "husky",
84
+ "prepare": "lefthook install",
87
85
  "prepublishOnly": "npm run build",
88
86
  "pretest:benchmark": "npm run build",
89
87
  "pretest:browser": "./scripts/iodd && npm run build && npm-run-all --parallel examples:browser:**",
90
88
  "pretest:node": "npm run build",
91
89
  "pretest": "npm run build",
92
- "prettier:check": "prettier --check .",
93
- "prettier:fix": "prettier --write .",
90
+ "format": "biome format --write .",
91
+ "format:check": "biome format --check .",
94
92
  "release": "standard-version --no-verify",
95
93
  "test:benchmark": "cd examples/benchmark && npm test",
96
94
  "test:browser": "wdio run ./wdio.conf.js",
@@ -104,16 +102,13 @@
104
102
  },
105
103
  "lint-staged": {
106
104
  "*": [
107
- "prettier --no-error-on-unmatched-pattern --write"
108
- ],
109
- "*.{js,jsx}": [
110
- "eslint --no-error-on-unmatched-pattern --fix"
105
+ "biome check --write --no-errors-on-unmatched"
111
106
  ]
112
107
  },
113
108
  "standard-version": {
114
109
  "scripts": {
115
- "postchangelog": "prettier --write CHANGELOG.md"
110
+ "postchangelog": "biome format --write CHANGELOG.md"
116
111
  }
117
112
  },
118
- "packageManager": "npm@11.3.0"
113
+ "packageManager": "npm@11.12.1"
119
114
  }
package/dist/native.d.ts DELETED
@@ -1,4 +0,0 @@
1
- declare const _default: {
2
- randomUUID: false | (() => `${string}-${string}-${string}-${string}-${string}`);
3
- };
4
- export default _default;
package/dist/native.js DELETED
@@ -1,2 +0,0 @@
1
- const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
2
- export default { randomUUID };
@@ -1,2 +0,0 @@
1
- import { randomUUID } from 'node:crypto';
2
- export default { randomUUID };