uuid 11.0.4 → 11.1.0

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.
Files changed (68) hide show
  1. package/README.md +12 -12
  2. package/dist/cjs/md5.d.ts +3 -1
  3. package/dist/cjs/native.d.ts +1 -0
  4. package/dist/cjs/parse.d.ts +1 -1
  5. package/dist/cjs/rng.d.ts +1 -1
  6. package/dist/cjs/rng.js +1 -1
  7. package/dist/cjs/sha1.d.ts +3 -1
  8. package/dist/cjs/stringify.js +2 -1
  9. package/dist/cjs/types.d.ts +1 -1
  10. package/dist/cjs/v1.d.ts +1 -1
  11. package/dist/cjs/v1.js +3 -2
  12. package/dist/cjs/v1ToV6.js +1 -1
  13. package/dist/cjs/v3.d.ts +1 -1
  14. package/dist/cjs/v35.d.ts +2 -2
  15. package/dist/cjs/v35.js +3 -3
  16. package/dist/cjs/v4.d.ts +1 -1
  17. package/dist/cjs/v5.d.ts +1 -1
  18. package/dist/cjs/v6.d.ts +1 -1
  19. package/dist/cjs/v6ToV1.js +1 -1
  20. package/dist/cjs/v7.d.ts +1 -1
  21. package/dist/cjs/v7.js +3 -2
  22. package/dist/cjs-browser/md5.d.ts +1 -1
  23. package/dist/cjs-browser/parse.d.ts +1 -1
  24. package/dist/cjs-browser/rng.d.ts +1 -1
  25. package/dist/cjs-browser/rng.js +1 -1
  26. package/dist/cjs-browser/stringify.js +2 -1
  27. package/dist/cjs-browser/types.d.ts +1 -1
  28. package/dist/cjs-browser/v1.d.ts +1 -1
  29. package/dist/cjs-browser/v1.js +3 -2
  30. package/dist/cjs-browser/v1ToV6.js +1 -1
  31. package/dist/cjs-browser/v3.d.ts +1 -1
  32. package/dist/cjs-browser/v35.d.ts +2 -2
  33. package/dist/cjs-browser/v35.js +3 -3
  34. package/dist/cjs-browser/v4.d.ts +1 -1
  35. package/dist/cjs-browser/v5.d.ts +1 -1
  36. package/dist/cjs-browser/v6.d.ts +1 -1
  37. package/dist/cjs-browser/v6ToV1.js +1 -1
  38. package/dist/cjs-browser/v7.d.ts +1 -1
  39. package/dist/cjs-browser/v7.js +3 -2
  40. package/dist/esm/md5.d.ts +3 -1
  41. package/dist/esm/native.d.ts +1 -0
  42. package/dist/esm/parse.d.ts +1 -1
  43. package/dist/esm/rng.d.ts +1 -1
  44. package/dist/esm/sha1.d.ts +3 -1
  45. package/dist/esm/types.d.ts +1 -1
  46. package/dist/esm/v1.d.ts +1 -1
  47. package/dist/esm/v1.js +1 -1
  48. package/dist/esm/v3.d.ts +1 -1
  49. package/dist/esm/v35.d.ts +2 -2
  50. package/dist/esm/v4.d.ts +1 -1
  51. package/dist/esm/v5.d.ts +1 -1
  52. package/dist/esm/v6.d.ts +1 -1
  53. package/dist/esm/v7.d.ts +1 -1
  54. package/dist/esm/v7.js +1 -1
  55. package/dist/esm-browser/md5.d.ts +1 -1
  56. package/dist/esm-browser/parse.d.ts +1 -1
  57. package/dist/esm-browser/rng.d.ts +1 -1
  58. package/dist/esm-browser/types.d.ts +1 -1
  59. package/dist/esm-browser/v1.d.ts +1 -1
  60. package/dist/esm-browser/v1.js +1 -1
  61. package/dist/esm-browser/v3.d.ts +1 -1
  62. package/dist/esm-browser/v35.d.ts +2 -2
  63. package/dist/esm-browser/v4.d.ts +1 -1
  64. package/dist/esm-browser/v5.d.ts +1 -1
  65. package/dist/esm-browser/v6.d.ts +1 -1
  66. package/dist/esm-browser/v7.d.ts +1 -1
  67. package/dist/esm-browser/v7.js +1 -1
  68. package/package.json +11 -10
package/README.md CHANGED
@@ -2,24 +2,24 @@
2
2
  -- This file is auto-generated from README_js.md. Changes should be made there.
3
3
  -->
4
4
 
5
- # uuid [![CI](https://github.com/uuidjs/uuid/workflows/CI/badge.svg)](https://github.com/uuidjs/uuid/actions?query=workflow%3ACI) [![Browser](https://github.com/uuidjs/uuid/workflows/Browser/badge.svg)](https://github.com/uuidjs/uuid/actions?query=workflow%3ABrowser)
5
+ # uuid [![CI](https://github.com/uuidjs/uuid/workflows/CI/badge.svg)](https://github.com/uuidjs/uuid/actions?query=workflow%3ACI) [![Browser](https://github.com/uuidjs/uuid/workflows/Browser/badge.svg)](https://github.com/uuidjs/uuid/actions/workflows/browser.yml)
6
6
 
7
- For the creation of [RFC9562](https://www.rfc-editor.org/rfc/rfc9562.html) (formally [RFC4122](https://www.rfc-editor.org/rfc/rfc4122.html)) UUIDs
7
+ For the creation of [RFC9562](https://www.rfc-editor.org/rfc/rfc9562.html) (formerly [RFC4122](https://www.rfc-editor.org/rfc/rfc4122.html)) UUIDs
8
8
 
9
9
  - **Complete** - Support for all RFC9562 UUID versions
10
10
  - **Cross-platform** - Support for...
11
11
  - ESM & Common JS
12
- - [Chrome, Safari, Firefox, Edge browsers](#support)
12
+ - [Typescript](#support)
13
+ - [Chrome, Safari, Firefox, and Edge](#support)
13
14
  - [NodeJS](#support)
14
15
  - [React Native / Expo](#react-native--expo)
15
- - **Secure** - Cryptographically-strong random values
16
- - **Compact** - No dependencies, [tree-shakable](https://developer.mozilla.org/en-US/docs/Glossary/Tree_shaking)
17
- - **CLI** - Includes the [`uuid` command line](#command-line) utility
18
- - **Typescript** - Types now included
16
+ - **Secure** - Uses modern `crypto` API for random values
17
+ - **Compact** - Zero-dependency, [tree-shakable](https://developer.mozilla.org/en-US/docs/Glossary/Tree_shaking)
18
+ - **CLI** - [`uuid` command line](#command-line) utility
19
19
 
20
20
  <!-- prettier-ignore -->
21
21
  > [!NOTE]
22
- w> `uuid@11` is now available: See the [CHANGELOG](./CHANGELOG.md) for details. TL;DR:
22
+ > `uuid@11` is now available: See the [CHANGELOG](./CHANGELOG.md) for details. TL;DR:
23
23
  > * TypeScript support is now included (remove `@types/uuid` from your dependencies)
24
24
  > * Subtle changes to how the `options` arg is interpreted for `v1()`, `v6()`, and `v7()`. [See details](#options-handling-for-timestamp-uuids)
25
25
  > * Binary UUIDs are now `Uint8Array`s. (May impact callers of `parse()`, `stringify()`, or that pass an `option#buf` argument to `v1()`-`v7()`.)
@@ -180,7 +180,7 @@ Create an RFC version 1 (timestamp) UUID
180
180
  | [`options.nsecs = 0`] | RFC "timestamp" field (`Number` of nanoseconds to add to `msecs`, should be 0-10,000) |
181
181
  | [`options.random = (random)`] | `Array` of 16 random bytes (0-255) used to generate other fields, above |
182
182
  | [`options.rng`] | Alternative to `options.random`, a `Function` that returns an `Array` of 16 random bytes (0-255) |
183
- | [`buffer`] | `Array \| Buffer` If specified, uuid will be written here in byte-form, starting at `offset` |
183
+ | [`buffer`] | `Uint8Array` or `Uint8Array` subtype (e.g. Node.js `Buffer`). If provided, binary UUID is written into the array, starting at `offset` |
184
184
  | [`offset` = 0] | `Number` Index to start writing UUID bytes in `buffer` |
185
185
  | _returns_ | UUID `String` if no `buffer` is specified, otherwise returns `buffer` |
186
186
  | _throws_ | `Error` if more than 10M UUIDs/sec are requested |
@@ -244,7 +244,7 @@ Create an RFC version 4 (random) UUID
244
244
  | [`options`] | `Object` with one or more of the following properties: |
245
245
  | [`options.random`] | `Array` of 16 random bytes (0-255) |
246
246
  | [`options.rng`] | Alternative to `options.random`, a `Function` that returns an `Array` of 16 random bytes (0-255) |
247
- | [`buffer`] | `Array \| Buffer` If specified, uuid will be written here in byte-form, starting at `offset` |
247
+ | [`buffer`] | `Uint8Array` or `Uint8Array` subtype (e.g. Node.js `Buffer`). If provided, binary UUID is written into the array, starting at `offset` |
248
248
  | [`offset` = 0] | `Number` Index to start writing UUID bytes in `buffer` |
249
249
  | _returns_ | UUID `String` if no `buffer` is specified, otherwise returns `buffer` |
250
250
 
@@ -292,7 +292,7 @@ Create an RFC version 5 (namespace w/ SHA-1) UUID
292
292
  | --- | --- |
293
293
  | `name` | `String \| Array` |
294
294
  | `namespace` | `String \| Array[16]` Namespace UUID |
295
- | [`buffer`] | `Array \| Buffer` If specified, uuid will be written here in byte-form, starting at `offset` |
295
+ | [`buffer`] | `Uint8Array` or `Uint8Array` subtype (e.g. Node.js `Buffer`). If provided, binary UUID is written into the array, starting at `offset` |
296
296
  | [`offset` = 0] | `Number` Index to start writing UUID bytes in `buffer` |
297
297
  | _returns_ | UUID `String` if no `buffer` is specified, otherwise returns `buffer` |
298
298
 
@@ -367,7 +367,7 @@ Create an RFC version 7 (random) UUID
367
367
  | [`options.random = (random)`] | `Array` of 16 random bytes (0-255) used to generate other fields, above |
368
368
  | [`options.rng`] | Alternative to `options.random`, a `Function` that returns an `Array` of 16 random bytes (0-255) |
369
369
  | [`options.seq = (random)`] | 32-bit sequence `Number` between 0 - 0xffffffff. This may be provided to help ensure uniqueness for UUIDs generated within the same millisecond time interval. Default = random value. |
370
- | [`buffer`] | `Array \| Buffer` If specified, uuid will be written here in byte-form, starting at `offset` |
370
+ | [`buffer`] | `Uint8Array` or `Uint8Array` subtype (e.g. Node.js `Buffer`). If provided, binary UUID is written into the array, starting at `offset` |
371
371
  | [`offset` = 0] | `Number` Index to start writing UUID bytes in `buffer` |
372
372
  | _returns_ | UUID `String` if no `buffer` is specified, otherwise returns `buffer` |
373
373
 
package/dist/cjs/md5.d.ts CHANGED
@@ -1,2 +1,4 @@
1
- declare function md5(bytes: Uint8Array): Buffer<ArrayBufferLike>;
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ declare function md5(bytes: Uint8Array): Buffer;
2
4
  export default md5;
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" />
1
2
  import { randomUUID } from 'crypto';
2
3
  declare const _default: {
3
4
  randomUUID: typeof randomUUID;
@@ -1,2 +1,2 @@
1
- declare function parse(uuid: string): Uint8Array<ArrayBuffer>;
1
+ declare function parse(uuid: string): Uint8Array;
2
2
  export default parse;
package/dist/cjs/rng.d.ts CHANGED
@@ -1 +1 @@
1
- export default function rng(): Uint8Array<ArrayBuffer>;
1
+ export default function rng(): Uint8Array;
package/dist/cjs/rng.js CHANGED
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = rng;
4
3
  const crypto_1 = require("crypto");
5
4
  const rnds8Pool = new Uint8Array(256);
6
5
  let poolPtr = rnds8Pool.length;
@@ -11,3 +10,4 @@ function rng() {
11
10
  }
12
11
  return rnds8Pool.slice(poolPtr, (poolPtr += 16));
13
12
  }
13
+ exports.default = rng;
@@ -1,2 +1,4 @@
1
- declare function sha1(bytes: Uint8Array): Buffer<ArrayBufferLike>;
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ declare function sha1(bytes: Uint8Array): Buffer;
2
4
  export default sha1;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.unsafeStringify = unsafeStringify;
3
+ exports.unsafeStringify = void 0;
4
4
  const validate_js_1 = require("./validate.js");
5
5
  const byteToHex = [];
6
6
  for (let i = 0; i < 256; ++i) {
@@ -28,6 +28,7 @@ function unsafeStringify(arr, offset = 0) {
28
28
  byteToHex[arr[offset + 14]] +
29
29
  byteToHex[arr[offset + 15]]).toLowerCase();
30
30
  }
31
+ exports.unsafeStringify = unsafeStringify;
31
32
  function stringify(arr, offset = 0) {
32
33
  const uuid = unsafeStringify(arr, offset);
33
34
  if (!(0, validate_js_1.default)(uuid)) {
@@ -1,4 +1,4 @@
1
- export type UUIDTypes = string | Uint8Array;
1
+ export type UUIDTypes<TBuf extends Uint8Array = Uint8Array> = string | TBuf;
2
2
  export type Version1Options = {
3
3
  node?: Uint8Array;
4
4
  clockseq?: number;
package/dist/cjs/v1.d.ts CHANGED
@@ -6,6 +6,6 @@ type V1State = {
6
6
  nsecs?: number;
7
7
  };
8
8
  declare function v1(options?: Version1Options, buf?: undefined, offset?: number): string;
9
- declare function v1(options: Version1Options | undefined, buf: Uint8Array, offset?: number): Uint8Array;
9
+ declare function v1<Buf extends Uint8Array = Uint8Array>(options: Version1Options | undefined, buf: Buf, offset?: number): Buf;
10
10
  export declare function updateV1State(state: V1State, now: number, rnds: Uint8Array): V1State;
11
11
  export default v1;
package/dist/cjs/v1.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.updateV1State = updateV1State;
3
+ exports.updateV1State = void 0;
4
4
  const rng_js_1 = require("./rng.js");
5
5
  const stringify_js_1 = require("./stringify.js");
6
6
  const _state = {};
@@ -22,7 +22,7 @@ function v1(options, buf, offset) {
22
22
  updateV1State(_state, now, rnds);
23
23
  bytes = v1Bytes(rnds, _state.msecs, _state.nsecs, isV6 ? undefined : _state.clockseq, isV6 ? undefined : _state.node, buf, offset);
24
24
  }
25
- return buf ? bytes : (0, stringify_js_1.unsafeStringify)(bytes);
25
+ return buf ?? (0, stringify_js_1.unsafeStringify)(bytes);
26
26
  }
27
27
  function updateV1State(state, now, rnds) {
28
28
  state.msecs ??= -Infinity;
@@ -48,6 +48,7 @@ function updateV1State(state, now, rnds) {
48
48
  state.msecs = now;
49
49
  return state;
50
50
  }
51
+ exports.updateV1State = updateV1State;
51
52
  function v1Bytes(rnds, msecs, nsecs, clockseq, node, buf, offset = 0) {
52
53
  if (rnds.length < 16) {
53
54
  throw new Error('Random bytes length must be >= 16');
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = v1ToV6;
4
3
  const parse_js_1 = require("./parse.js");
5
4
  const stringify_js_1 = require("./stringify.js");
6
5
  function v1ToV6(uuid) {
@@ -8,6 +7,7 @@ function v1ToV6(uuid) {
8
7
  const v6Bytes = _v1ToV6(v1Bytes);
9
8
  return typeof uuid === 'string' ? (0, stringify_js_1.unsafeStringify)(v6Bytes) : v6Bytes;
10
9
  }
10
+ exports.default = v1ToV6;
11
11
  function _v1ToV6(v1Bytes) {
12
12
  return Uint8Array.of(((v1Bytes[6] & 0x0f) << 4) | ((v1Bytes[7] >> 4) & 0x0f), ((v1Bytes[7] & 0x0f) << 4) | ((v1Bytes[4] & 0xf0) >> 4), ((v1Bytes[4] & 0x0f) << 4) | ((v1Bytes[5] & 0xf0) >> 4), ((v1Bytes[5] & 0x0f) << 4) | ((v1Bytes[0] & 0xf0) >> 4), ((v1Bytes[0] & 0x0f) << 4) | ((v1Bytes[1] & 0xf0) >> 4), ((v1Bytes[1] & 0x0f) << 4) | ((v1Bytes[2] & 0xf0) >> 4), 0x60 | (v1Bytes[2] & 0x0f), v1Bytes[3], v1Bytes[8], v1Bytes[9], v1Bytes[10], v1Bytes[11], v1Bytes[12], v1Bytes[13], v1Bytes[14], v1Bytes[15]);
13
13
  }
package/dist/cjs/v3.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { 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
- declare function v3(value: string | Uint8Array, namespace: UUIDTypes, buf: Uint8Array, offset?: number): Uint8Array;
4
+ declare function v3<TBuf extends Uint8Array = Uint8Array>(value: string | Uint8Array, namespace: UUIDTypes, buf: TBuf, offset?: number): TBuf;
5
5
  declare namespace v3 {
6
6
  var DNS: string;
7
7
  var URL: string;
package/dist/cjs/v35.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { UUIDTypes } from './types.js';
2
- export declare function stringToBytes(str: string): Uint8Array<ArrayBuffer>;
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";
5
5
  type HashFunction = (bytes: Uint8Array) => Uint8Array;
6
- export default function v35(version: 0x30 | 0x50, hash: HashFunction, value: string | Uint8Array, namespace: UUIDTypes, buf?: Uint8Array, offset?: number): string | Uint8Array<ArrayBufferLike>;
6
+ export default function v35<TBuf extends Uint8Array = Uint8Array>(version: 0x30 | 0x50, hash: HashFunction, value: string | Uint8Array, namespace: UUIDTypes, buf?: TBuf, offset?: number): UUIDTypes<TBuf>;
7
7
  export {};
package/dist/cjs/v35.js CHANGED
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.URL = exports.DNS = void 0;
4
- exports.stringToBytes = stringToBytes;
5
- exports.default = v35;
3
+ exports.URL = exports.DNS = exports.stringToBytes = void 0;
6
4
  const parse_js_1 = require("./parse.js");
7
5
  const stringify_js_1 = require("./stringify.js");
8
6
  function stringToBytes(str) {
@@ -13,6 +11,7 @@ function stringToBytes(str) {
13
11
  }
14
12
  return bytes;
15
13
  }
14
+ exports.stringToBytes = stringToBytes;
16
15
  exports.DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
17
16
  exports.URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
18
17
  function v35(version, hash, value, namespace, buf, offset) {
@@ -39,3 +38,4 @@ function v35(version, hash, value, namespace, buf, offset) {
39
38
  }
40
39
  return (0, stringify_js_1.unsafeStringify)(bytes);
41
40
  }
41
+ exports.default = v35;
package/dist/cjs/v4.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import { Version4Options } from './types.js';
2
2
  declare function v4(options?: Version4Options, buf?: undefined, offset?: number): string;
3
- declare function v4(options: Version4Options | undefined, buf: Uint8Array, offset?: number): Uint8Array;
3
+ declare function v4<TBuf extends Uint8Array = Uint8Array>(options: Version4Options | undefined, buf: TBuf, offset?: number): TBuf;
4
4
  export default v4;
package/dist/cjs/v5.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { 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
- declare function v5(value: string | Uint8Array, namespace: UUIDTypes, buf: Uint8Array, offset?: number): Uint8Array;
4
+ declare function v5<TBuf extends Uint8Array = Uint8Array>(value: string | Uint8Array, namespace: UUIDTypes, buf: TBuf, offset?: number): TBuf;
5
5
  declare namespace v5 {
6
6
  var DNS: string;
7
7
  var URL: string;
package/dist/cjs/v6.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import { Version6Options } from './types.js';
2
2
  declare function v6(options?: Version6Options, buf?: undefined, offset?: number): string;
3
- declare function v6(options: Version6Options | undefined, buf: Uint8Array, offset?: number): Uint8Array;
3
+ declare function v6<TBuf extends Uint8Array = Uint8Array>(options: Version6Options | undefined, buf: TBuf, offset?: number): TBuf;
4
4
  export default v6;
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = v6ToV1;
4
3
  const parse_js_1 = require("./parse.js");
5
4
  const stringify_js_1 = require("./stringify.js");
6
5
  function v6ToV1(uuid) {
@@ -8,6 +7,7 @@ function v6ToV1(uuid) {
8
7
  const v1Bytes = _v6ToV1(v6Bytes);
9
8
  return typeof uuid === 'string' ? (0, stringify_js_1.unsafeStringify)(v1Bytes) : v1Bytes;
10
9
  }
10
+ exports.default = v6ToV1;
11
11
  function _v6ToV1(v6Bytes) {
12
12
  return Uint8Array.of(((v6Bytes[3] & 0x0f) << 4) | ((v6Bytes[4] >> 4) & 0x0f), ((v6Bytes[4] & 0x0f) << 4) | ((v6Bytes[5] & 0xf0) >> 4), ((v6Bytes[5] & 0x0f) << 4) | (v6Bytes[6] & 0x0f), v6Bytes[7], ((v6Bytes[1] & 0x0f) << 4) | ((v6Bytes[2] & 0xf0) >> 4), ((v6Bytes[2] & 0x0f) << 4) | ((v6Bytes[3] & 0xf0) >> 4), 0x10 | ((v6Bytes[0] & 0xf0) >> 4), ((v6Bytes[0] & 0x0f) << 4) | ((v6Bytes[1] & 0xf0) >> 4), v6Bytes[8], v6Bytes[9], v6Bytes[10], v6Bytes[11], v6Bytes[12], v6Bytes[13], v6Bytes[14], v6Bytes[15]);
13
13
  }
package/dist/cjs/v7.d.ts CHANGED
@@ -4,6 +4,6 @@ type V7State = {
4
4
  seq?: number;
5
5
  };
6
6
  declare function v7(options?: Version7Options, buf?: undefined, offset?: number): string;
7
- declare function v7(options: Version7Options | undefined, buf: Uint8Array, offset?: number): Uint8Array;
7
+ declare function v7<TBuf extends Uint8Array = Uint8Array>(options: Version7Options | undefined, buf: TBuf, offset?: number): TBuf;
8
8
  export declare function updateV7State(state: V7State, now: number, rnds: Uint8Array): V7State;
9
9
  export default v7;
package/dist/cjs/v7.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.updateV7State = updateV7State;
3
+ exports.updateV7State = void 0;
4
4
  const rng_js_1 = require("./rng.js");
5
5
  const stringify_js_1 = require("./stringify.js");
6
6
  const _state = {};
@@ -15,7 +15,7 @@ function v7(options, buf, offset) {
15
15
  updateV7State(_state, now, rnds);
16
16
  bytes = v7Bytes(rnds, _state.msecs, _state.seq, buf, offset);
17
17
  }
18
- return buf ? bytes : (0, stringify_js_1.unsafeStringify)(bytes);
18
+ return buf ?? (0, stringify_js_1.unsafeStringify)(bytes);
19
19
  }
20
20
  function updateV7State(state, now, rnds) {
21
21
  state.msecs ??= -Infinity;
@@ -32,6 +32,7 @@ function updateV7State(state, now, rnds) {
32
32
  }
33
33
  return state;
34
34
  }
35
+ exports.updateV7State = updateV7State;
35
36
  function v7Bytes(rnds, msecs, seq, buf, offset = 0) {
36
37
  if (rnds.length < 16) {
37
38
  throw new Error('Random bytes length must be >= 16');
@@ -1,2 +1,2 @@
1
- declare function md5(bytes: Uint8Array): Uint8Array<ArrayBuffer>;
1
+ declare function md5(bytes: Uint8Array): Uint8Array;
2
2
  export default md5;
@@ -1,2 +1,2 @@
1
- declare function parse(uuid: string): Uint8Array<ArrayBuffer>;
1
+ declare function parse(uuid: string): Uint8Array;
2
2
  export default parse;
@@ -1 +1 @@
1
- export default function rng(): Uint8Array<ArrayBuffer>;
1
+ export default function rng(): Uint8Array;
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = rng;
4
3
  let getRandomValues;
5
4
  const rnds8 = new Uint8Array(16);
6
5
  function rng() {
@@ -12,3 +11,4 @@ function rng() {
12
11
  }
13
12
  return getRandomValues(rnds8);
14
13
  }
14
+ exports.default = rng;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.unsafeStringify = unsafeStringify;
3
+ exports.unsafeStringify = void 0;
4
4
  const validate_js_1 = require("./validate.js");
5
5
  const byteToHex = [];
6
6
  for (let i = 0; i < 256; ++i) {
@@ -28,6 +28,7 @@ function unsafeStringify(arr, offset = 0) {
28
28
  byteToHex[arr[offset + 14]] +
29
29
  byteToHex[arr[offset + 15]]).toLowerCase();
30
30
  }
31
+ exports.unsafeStringify = unsafeStringify;
31
32
  function stringify(arr, offset = 0) {
32
33
  const uuid = unsafeStringify(arr, offset);
33
34
  if (!(0, validate_js_1.default)(uuid)) {
@@ -1,4 +1,4 @@
1
- export type UUIDTypes = string | Uint8Array;
1
+ export type UUIDTypes<TBuf extends Uint8Array = Uint8Array> = string | TBuf;
2
2
  export type Version1Options = {
3
3
  node?: Uint8Array;
4
4
  clockseq?: number;
@@ -6,6 +6,6 @@ type V1State = {
6
6
  nsecs?: number;
7
7
  };
8
8
  declare function v1(options?: Version1Options, buf?: undefined, offset?: number): string;
9
- declare function v1(options: Version1Options | undefined, buf: Uint8Array, offset?: number): Uint8Array;
9
+ declare function v1<Buf extends Uint8Array = Uint8Array>(options: Version1Options | undefined, buf: Buf, offset?: number): Buf;
10
10
  export declare function updateV1State(state: V1State, now: number, rnds: Uint8Array): V1State;
11
11
  export default v1;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.updateV1State = updateV1State;
3
+ exports.updateV1State = void 0;
4
4
  const rng_js_1 = require("./rng.js");
5
5
  const stringify_js_1 = require("./stringify.js");
6
6
  const _state = {};
@@ -22,7 +22,7 @@ function v1(options, buf, offset) {
22
22
  updateV1State(_state, now, rnds);
23
23
  bytes = v1Bytes(rnds, _state.msecs, _state.nsecs, isV6 ? undefined : _state.clockseq, isV6 ? undefined : _state.node, buf, offset);
24
24
  }
25
- return buf ? bytes : (0, stringify_js_1.unsafeStringify)(bytes);
25
+ return buf ?? (0, stringify_js_1.unsafeStringify)(bytes);
26
26
  }
27
27
  function updateV1State(state, now, rnds) {
28
28
  state.msecs ??= -Infinity;
@@ -48,6 +48,7 @@ function updateV1State(state, now, rnds) {
48
48
  state.msecs = now;
49
49
  return state;
50
50
  }
51
+ exports.updateV1State = updateV1State;
51
52
  function v1Bytes(rnds, msecs, nsecs, clockseq, node, buf, offset = 0) {
52
53
  if (rnds.length < 16) {
53
54
  throw new Error('Random bytes length must be >= 16');
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = v1ToV6;
4
3
  const parse_js_1 = require("./parse.js");
5
4
  const stringify_js_1 = require("./stringify.js");
6
5
  function v1ToV6(uuid) {
@@ -8,6 +7,7 @@ function v1ToV6(uuid) {
8
7
  const v6Bytes = _v1ToV6(v1Bytes);
9
8
  return typeof uuid === 'string' ? (0, stringify_js_1.unsafeStringify)(v6Bytes) : v6Bytes;
10
9
  }
10
+ exports.default = v1ToV6;
11
11
  function _v1ToV6(v1Bytes) {
12
12
  return Uint8Array.of(((v1Bytes[6] & 0x0f) << 4) | ((v1Bytes[7] >> 4) & 0x0f), ((v1Bytes[7] & 0x0f) << 4) | ((v1Bytes[4] & 0xf0) >> 4), ((v1Bytes[4] & 0x0f) << 4) | ((v1Bytes[5] & 0xf0) >> 4), ((v1Bytes[5] & 0x0f) << 4) | ((v1Bytes[0] & 0xf0) >> 4), ((v1Bytes[0] & 0x0f) << 4) | ((v1Bytes[1] & 0xf0) >> 4), ((v1Bytes[1] & 0x0f) << 4) | ((v1Bytes[2] & 0xf0) >> 4), 0x60 | (v1Bytes[2] & 0x0f), v1Bytes[3], v1Bytes[8], v1Bytes[9], v1Bytes[10], v1Bytes[11], v1Bytes[12], v1Bytes[13], v1Bytes[14], v1Bytes[15]);
13
13
  }
@@ -1,7 +1,7 @@
1
1
  import { 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
- declare function v3(value: string | Uint8Array, namespace: UUIDTypes, buf: Uint8Array, offset?: number): Uint8Array;
4
+ declare function v3<TBuf extends Uint8Array = Uint8Array>(value: string | Uint8Array, namespace: UUIDTypes, buf: TBuf, offset?: number): TBuf;
5
5
  declare namespace v3 {
6
6
  var DNS: string;
7
7
  var URL: string;
@@ -1,7 +1,7 @@
1
1
  import { UUIDTypes } from './types.js';
2
- export declare function stringToBytes(str: string): Uint8Array<ArrayBuffer>;
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";
5
5
  type HashFunction = (bytes: Uint8Array) => Uint8Array;
6
- export default function v35(version: 0x30 | 0x50, hash: HashFunction, value: string | Uint8Array, namespace: UUIDTypes, buf?: Uint8Array, offset?: number): string | Uint8Array<ArrayBufferLike>;
6
+ export default function v35<TBuf extends Uint8Array = Uint8Array>(version: 0x30 | 0x50, hash: HashFunction, value: string | Uint8Array, namespace: UUIDTypes, buf?: TBuf, offset?: number): UUIDTypes<TBuf>;
7
7
  export {};
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.URL = exports.DNS = void 0;
4
- exports.stringToBytes = stringToBytes;
5
- exports.default = v35;
3
+ exports.URL = exports.DNS = exports.stringToBytes = void 0;
6
4
  const parse_js_1 = require("./parse.js");
7
5
  const stringify_js_1 = require("./stringify.js");
8
6
  function stringToBytes(str) {
@@ -13,6 +11,7 @@ function stringToBytes(str) {
13
11
  }
14
12
  return bytes;
15
13
  }
14
+ exports.stringToBytes = stringToBytes;
16
15
  exports.DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
17
16
  exports.URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
18
17
  function v35(version, hash, value, namespace, buf, offset) {
@@ -39,3 +38,4 @@ function v35(version, hash, value, namespace, buf, offset) {
39
38
  }
40
39
  return (0, stringify_js_1.unsafeStringify)(bytes);
41
40
  }
41
+ exports.default = v35;
@@ -1,4 +1,4 @@
1
1
  import { Version4Options } from './types.js';
2
2
  declare function v4(options?: Version4Options, buf?: undefined, offset?: number): string;
3
- declare function v4(options: Version4Options | undefined, buf: Uint8Array, offset?: number): Uint8Array;
3
+ declare function v4<TBuf extends Uint8Array = Uint8Array>(options: Version4Options | undefined, buf: TBuf, offset?: number): TBuf;
4
4
  export default v4;
@@ -1,7 +1,7 @@
1
1
  import { 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
- declare function v5(value: string | Uint8Array, namespace: UUIDTypes, buf: Uint8Array, offset?: number): Uint8Array;
4
+ declare function v5<TBuf extends Uint8Array = Uint8Array>(value: string | Uint8Array, namespace: UUIDTypes, buf: TBuf, offset?: number): TBuf;
5
5
  declare namespace v5 {
6
6
  var DNS: string;
7
7
  var URL: string;
@@ -1,4 +1,4 @@
1
1
  import { Version6Options } from './types.js';
2
2
  declare function v6(options?: Version6Options, buf?: undefined, offset?: number): string;
3
- declare function v6(options: Version6Options | undefined, buf: Uint8Array, offset?: number): Uint8Array;
3
+ declare function v6<TBuf extends Uint8Array = Uint8Array>(options: Version6Options | undefined, buf: TBuf, offset?: number): TBuf;
4
4
  export default v6;
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = v6ToV1;
4
3
  const parse_js_1 = require("./parse.js");
5
4
  const stringify_js_1 = require("./stringify.js");
6
5
  function v6ToV1(uuid) {
@@ -8,6 +7,7 @@ function v6ToV1(uuid) {
8
7
  const v1Bytes = _v6ToV1(v6Bytes);
9
8
  return typeof uuid === 'string' ? (0, stringify_js_1.unsafeStringify)(v1Bytes) : v1Bytes;
10
9
  }
10
+ exports.default = v6ToV1;
11
11
  function _v6ToV1(v6Bytes) {
12
12
  return Uint8Array.of(((v6Bytes[3] & 0x0f) << 4) | ((v6Bytes[4] >> 4) & 0x0f), ((v6Bytes[4] & 0x0f) << 4) | ((v6Bytes[5] & 0xf0) >> 4), ((v6Bytes[5] & 0x0f) << 4) | (v6Bytes[6] & 0x0f), v6Bytes[7], ((v6Bytes[1] & 0x0f) << 4) | ((v6Bytes[2] & 0xf0) >> 4), ((v6Bytes[2] & 0x0f) << 4) | ((v6Bytes[3] & 0xf0) >> 4), 0x10 | ((v6Bytes[0] & 0xf0) >> 4), ((v6Bytes[0] & 0x0f) << 4) | ((v6Bytes[1] & 0xf0) >> 4), v6Bytes[8], v6Bytes[9], v6Bytes[10], v6Bytes[11], v6Bytes[12], v6Bytes[13], v6Bytes[14], v6Bytes[15]);
13
13
  }
@@ -4,6 +4,6 @@ type V7State = {
4
4
  seq?: number;
5
5
  };
6
6
  declare function v7(options?: Version7Options, buf?: undefined, offset?: number): string;
7
- declare function v7(options: Version7Options | undefined, buf: Uint8Array, offset?: number): Uint8Array;
7
+ declare function v7<TBuf extends Uint8Array = Uint8Array>(options: Version7Options | undefined, buf: TBuf, offset?: number): TBuf;
8
8
  export declare function updateV7State(state: V7State, now: number, rnds: Uint8Array): V7State;
9
9
  export default v7;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.updateV7State = updateV7State;
3
+ exports.updateV7State = void 0;
4
4
  const rng_js_1 = require("./rng.js");
5
5
  const stringify_js_1 = require("./stringify.js");
6
6
  const _state = {};
@@ -15,7 +15,7 @@ function v7(options, buf, offset) {
15
15
  updateV7State(_state, now, rnds);
16
16
  bytes = v7Bytes(rnds, _state.msecs, _state.seq, buf, offset);
17
17
  }
18
- return buf ? bytes : (0, stringify_js_1.unsafeStringify)(bytes);
18
+ return buf ?? (0, stringify_js_1.unsafeStringify)(bytes);
19
19
  }
20
20
  function updateV7State(state, now, rnds) {
21
21
  state.msecs ??= -Infinity;
@@ -32,6 +32,7 @@ function updateV7State(state, now, rnds) {
32
32
  }
33
33
  return state;
34
34
  }
35
+ exports.updateV7State = updateV7State;
35
36
  function v7Bytes(rnds, msecs, seq, buf, offset = 0) {
36
37
  if (rnds.length < 16) {
37
38
  throw new Error('Random bytes length must be >= 16');
package/dist/esm/md5.d.ts CHANGED
@@ -1,2 +1,4 @@
1
- declare function md5(bytes: Uint8Array): Buffer<ArrayBufferLike>;
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ /// <reference types="node" resolution-mode="require"/>
3
+ declare function md5(bytes: Uint8Array): Buffer;
2
4
  export default md5;
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" resolution-mode="require"/>
1
2
  import { randomUUID } from 'crypto';
2
3
  declare const _default: {
3
4
  randomUUID: typeof randomUUID;
@@ -1,2 +1,2 @@
1
- declare function parse(uuid: string): Uint8Array<ArrayBuffer>;
1
+ declare function parse(uuid: string): Uint8Array;
2
2
  export default parse;
package/dist/esm/rng.d.ts CHANGED
@@ -1 +1 @@
1
- export default function rng(): Uint8Array<ArrayBuffer>;
1
+ export default function rng(): Uint8Array;
@@ -1,2 +1,4 @@
1
- declare function sha1(bytes: Uint8Array): Buffer<ArrayBufferLike>;
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ /// <reference types="node" resolution-mode="require"/>
3
+ declare function sha1(bytes: Uint8Array): Buffer;
2
4
  export default sha1;
@@ -1,4 +1,4 @@
1
- export type UUIDTypes = string | Uint8Array;
1
+ export type UUIDTypes<TBuf extends Uint8Array = Uint8Array> = string | TBuf;
2
2
  export type Version1Options = {
3
3
  node?: Uint8Array;
4
4
  clockseq?: number;
package/dist/esm/v1.d.ts CHANGED
@@ -6,6 +6,6 @@ type V1State = {
6
6
  nsecs?: number;
7
7
  };
8
8
  declare function v1(options?: Version1Options, buf?: undefined, offset?: number): string;
9
- declare function v1(options: Version1Options | undefined, buf: Uint8Array, offset?: number): Uint8Array;
9
+ declare function v1<Buf extends Uint8Array = Uint8Array>(options: Version1Options | undefined, buf: Buf, offset?: number): Buf;
10
10
  export declare function updateV1State(state: V1State, now: number, rnds: Uint8Array): V1State;
11
11
  export default v1;
package/dist/esm/v1.js CHANGED
@@ -19,7 +19,7 @@ function v1(options, buf, offset) {
19
19
  updateV1State(_state, now, rnds);
20
20
  bytes = v1Bytes(rnds, _state.msecs, _state.nsecs, isV6 ? undefined : _state.clockseq, isV6 ? undefined : _state.node, buf, offset);
21
21
  }
22
- return buf ? bytes : unsafeStringify(bytes);
22
+ return buf ?? unsafeStringify(bytes);
23
23
  }
24
24
  export function updateV1State(state, now, rnds) {
25
25
  state.msecs ??= -Infinity;
package/dist/esm/v3.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { 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
- declare function v3(value: string | Uint8Array, namespace: UUIDTypes, buf: Uint8Array, offset?: number): Uint8Array;
4
+ declare function v3<TBuf extends Uint8Array = Uint8Array>(value: string | Uint8Array, namespace: UUIDTypes, buf: TBuf, offset?: number): TBuf;
5
5
  declare namespace v3 {
6
6
  var DNS: string;
7
7
  var URL: string;
package/dist/esm/v35.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { UUIDTypes } from './types.js';
2
- export declare function stringToBytes(str: string): Uint8Array<ArrayBuffer>;
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";
5
5
  type HashFunction = (bytes: Uint8Array) => Uint8Array;
6
- export default function v35(version: 0x30 | 0x50, hash: HashFunction, value: string | Uint8Array, namespace: UUIDTypes, buf?: Uint8Array, offset?: number): string | Uint8Array<ArrayBufferLike>;
6
+ export default function v35<TBuf extends Uint8Array = Uint8Array>(version: 0x30 | 0x50, hash: HashFunction, value: string | Uint8Array, namespace: UUIDTypes, buf?: TBuf, offset?: number): UUIDTypes<TBuf>;
7
7
  export {};
package/dist/esm/v4.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import { Version4Options } from './types.js';
2
2
  declare function v4(options?: Version4Options, buf?: undefined, offset?: number): string;
3
- declare function v4(options: Version4Options | undefined, buf: Uint8Array, offset?: number): Uint8Array;
3
+ declare function v4<TBuf extends Uint8Array = Uint8Array>(options: Version4Options | undefined, buf: TBuf, offset?: number): TBuf;
4
4
  export default v4;
package/dist/esm/v5.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { 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
- declare function v5(value: string | Uint8Array, namespace: UUIDTypes, buf: Uint8Array, offset?: number): Uint8Array;
4
+ declare function v5<TBuf extends Uint8Array = Uint8Array>(value: string | Uint8Array, namespace: UUIDTypes, buf: TBuf, offset?: number): TBuf;
5
5
  declare namespace v5 {
6
6
  var DNS: string;
7
7
  var URL: string;
package/dist/esm/v6.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import { Version6Options } from './types.js';
2
2
  declare function v6(options?: Version6Options, buf?: undefined, offset?: number): string;
3
- declare function v6(options: Version6Options | undefined, buf: Uint8Array, offset?: number): Uint8Array;
3
+ declare function v6<TBuf extends Uint8Array = Uint8Array>(options: Version6Options | undefined, buf: TBuf, offset?: number): TBuf;
4
4
  export default v6;
package/dist/esm/v7.d.ts CHANGED
@@ -4,6 +4,6 @@ type V7State = {
4
4
  seq?: number;
5
5
  };
6
6
  declare function v7(options?: Version7Options, buf?: undefined, offset?: number): string;
7
- declare function v7(options: Version7Options | undefined, buf: Uint8Array, offset?: number): Uint8Array;
7
+ declare function v7<TBuf extends Uint8Array = Uint8Array>(options: Version7Options | undefined, buf: TBuf, offset?: number): TBuf;
8
8
  export declare function updateV7State(state: V7State, now: number, rnds: Uint8Array): V7State;
9
9
  export default v7;
package/dist/esm/v7.js CHANGED
@@ -12,7 +12,7 @@ function v7(options, buf, offset) {
12
12
  updateV7State(_state, now, rnds);
13
13
  bytes = v7Bytes(rnds, _state.msecs, _state.seq, buf, offset);
14
14
  }
15
- return buf ? bytes : unsafeStringify(bytes);
15
+ return buf ?? unsafeStringify(bytes);
16
16
  }
17
17
  export function updateV7State(state, now, rnds) {
18
18
  state.msecs ??= -Infinity;
@@ -1,2 +1,2 @@
1
- declare function md5(bytes: Uint8Array): Uint8Array<ArrayBuffer>;
1
+ declare function md5(bytes: Uint8Array): Uint8Array;
2
2
  export default md5;
@@ -1,2 +1,2 @@
1
- declare function parse(uuid: string): Uint8Array<ArrayBuffer>;
1
+ declare function parse(uuid: string): Uint8Array;
2
2
  export default parse;
@@ -1 +1 @@
1
- export default function rng(): Uint8Array<ArrayBuffer>;
1
+ export default function rng(): Uint8Array;
@@ -1,4 +1,4 @@
1
- export type UUIDTypes = string | Uint8Array;
1
+ export type UUIDTypes<TBuf extends Uint8Array = Uint8Array> = string | TBuf;
2
2
  export type Version1Options = {
3
3
  node?: Uint8Array;
4
4
  clockseq?: number;
@@ -6,6 +6,6 @@ type V1State = {
6
6
  nsecs?: number;
7
7
  };
8
8
  declare function v1(options?: Version1Options, buf?: undefined, offset?: number): string;
9
- declare function v1(options: Version1Options | undefined, buf: Uint8Array, offset?: number): Uint8Array;
9
+ declare function v1<Buf extends Uint8Array = Uint8Array>(options: Version1Options | undefined, buf: Buf, offset?: number): Buf;
10
10
  export declare function updateV1State(state: V1State, now: number, rnds: Uint8Array): V1State;
11
11
  export default v1;
@@ -19,7 +19,7 @@ function v1(options, buf, offset) {
19
19
  updateV1State(_state, now, rnds);
20
20
  bytes = v1Bytes(rnds, _state.msecs, _state.nsecs, isV6 ? undefined : _state.clockseq, isV6 ? undefined : _state.node, buf, offset);
21
21
  }
22
- return buf ? bytes : unsafeStringify(bytes);
22
+ return buf ?? unsafeStringify(bytes);
23
23
  }
24
24
  export function updateV1State(state, now, rnds) {
25
25
  state.msecs ??= -Infinity;
@@ -1,7 +1,7 @@
1
1
  import { 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
- declare function v3(value: string | Uint8Array, namespace: UUIDTypes, buf: Uint8Array, offset?: number): Uint8Array;
4
+ declare function v3<TBuf extends Uint8Array = Uint8Array>(value: string | Uint8Array, namespace: UUIDTypes, buf: TBuf, offset?: number): TBuf;
5
5
  declare namespace v3 {
6
6
  var DNS: string;
7
7
  var URL: string;
@@ -1,7 +1,7 @@
1
1
  import { UUIDTypes } from './types.js';
2
- export declare function stringToBytes(str: string): Uint8Array<ArrayBuffer>;
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";
5
5
  type HashFunction = (bytes: Uint8Array) => Uint8Array;
6
- export default function v35(version: 0x30 | 0x50, hash: HashFunction, value: string | Uint8Array, namespace: UUIDTypes, buf?: Uint8Array, offset?: number): string | Uint8Array<ArrayBufferLike>;
6
+ export default function v35<TBuf extends Uint8Array = Uint8Array>(version: 0x30 | 0x50, hash: HashFunction, value: string | Uint8Array, namespace: UUIDTypes, buf?: TBuf, offset?: number): UUIDTypes<TBuf>;
7
7
  export {};
@@ -1,4 +1,4 @@
1
1
  import { Version4Options } from './types.js';
2
2
  declare function v4(options?: Version4Options, buf?: undefined, offset?: number): string;
3
- declare function v4(options: Version4Options | undefined, buf: Uint8Array, offset?: number): Uint8Array;
3
+ declare function v4<TBuf extends Uint8Array = Uint8Array>(options: Version4Options | undefined, buf: TBuf, offset?: number): TBuf;
4
4
  export default v4;
@@ -1,7 +1,7 @@
1
1
  import { 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
- declare function v5(value: string | Uint8Array, namespace: UUIDTypes, buf: Uint8Array, offset?: number): Uint8Array;
4
+ declare function v5<TBuf extends Uint8Array = Uint8Array>(value: string | Uint8Array, namespace: UUIDTypes, buf: TBuf, offset?: number): TBuf;
5
5
  declare namespace v5 {
6
6
  var DNS: string;
7
7
  var URL: string;
@@ -1,4 +1,4 @@
1
1
  import { Version6Options } from './types.js';
2
2
  declare function v6(options?: Version6Options, buf?: undefined, offset?: number): string;
3
- declare function v6(options: Version6Options | undefined, buf: Uint8Array, offset?: number): Uint8Array;
3
+ declare function v6<TBuf extends Uint8Array = Uint8Array>(options: Version6Options | undefined, buf: TBuf, offset?: number): TBuf;
4
4
  export default v6;
@@ -4,6 +4,6 @@ type V7State = {
4
4
  seq?: number;
5
5
  };
6
6
  declare function v7(options?: Version7Options, buf?: undefined, offset?: number): string;
7
- declare function v7(options: Version7Options | undefined, buf: Uint8Array, offset?: number): Uint8Array;
7
+ declare function v7<TBuf extends Uint8Array = Uint8Array>(options: Version7Options | undefined, buf: TBuf, offset?: number): TBuf;
8
8
  export declare function updateV7State(state: V7State, now: number, rnds: Uint8Array): V7State;
9
9
  export default v7;
@@ -12,7 +12,7 @@ function v7(options, buf, offset) {
12
12
  updateV7State(_state, now, rnds);
13
13
  bytes = v7Bytes(rnds, _state.msecs, _state.seq, buf, offset);
14
14
  }
15
- return buf ? bytes : unsafeStringify(bytes);
15
+ return buf ?? unsafeStringify(bytes);
16
16
  }
17
17
  export function updateV7State(state, now, rnds) {
18
18
  state.msecs ??= -Infinity;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uuid",
3
- "version": "11.0.4",
3
+ "version": "11.1.0",
4
4
  "description": "RFC9562 UUIDs",
5
5
  "type": "module",
6
6
  "funding": [
@@ -68,7 +68,7 @@
68
68
  "release-please": "16.15.0",
69
69
  "runmd": "1.4.1",
70
70
  "standard-version": "9.5.0",
71
- "typescript": "5.7.2",
71
+ "typescript": "5.0.4",
72
72
  "typescript-eslint": "8.18.2"
73
73
  },
74
74
  "optionalDevDependencies": {
@@ -87,15 +87,17 @@
87
87
  "docs": "npm run build && npx runmd --output=README.md README_js.md",
88
88
  "eslint:check": "eslint src/ test/ examples/ *.[jt]s",
89
89
  "eslint:fix": "eslint --fix src/ test/ examples/ *.[jt]s",
90
- "examples:browser:rollup:build": "cd examples/browser-rollup && npm install && npm run build",
91
- "examples:browser:webpack:build": "cd examples/browser-webpack && npm install && npm run build",
92
- "examples:node:commonjs:test": "cd examples/node-commonjs && npm install && npm test",
93
- "examples:node:esmodules:test": "cd examples/node-esmodules && npm install && npm test",
94
- "examples:node:jest:test": "cd examples/node-jest && npm install && npm test",
90
+ "examples:browser:rollup:build": "cd examples/browser-rollup && npm run build",
91
+ "examples:browser:webpack:build": "cd examples/browser-webpack && npm run build",
92
+ "examples:node:commonjs:test": "cd examples/node-commonjs && npm test",
93
+ "examples:node:esmodules:test": "cd examples/node-esmodules && npm test",
94
+ "examples:node:jest:test": "cd examples/node-jest && npm test",
95
+ "examples:node:typescript:test": "cd examples/typescript && npm test",
95
96
  "lint": "npm run eslint:check && npm run prettier:check",
96
97
  "md": "runmd --watch --output=README.md README_js.md",
97
- "prepack": "npm run build",
98
+ "prepack": "npm run build -- --no-pack",
98
99
  "prepare": "husky",
100
+ "prepublishOnly": "npm run build",
99
101
  "pretest:benchmark": "npm run build",
100
102
  "pretest:browser": "./scripts/iodd && npm run build && npm-run-all --parallel examples:browser:**",
101
103
  "pretest:node": "npm run build",
@@ -103,10 +105,9 @@
103
105
  "prettier:check": "prettier --check .",
104
106
  "prettier:fix": "prettier --write .",
105
107
  "release": "standard-version --no-verify",
106
- "test:benchmark": "cd examples/benchmark && HUSKY=0 npm install && npm test",
108
+ "test:benchmark": "cd examples/benchmark && npm test",
107
109
  "test:browser": "wdio run ./wdio.conf.js",
108
110
  "test:node": "npm-run-all --parallel examples:node:**",
109
- "test:pack": "./scripts/testpack.sh",
110
111
  "test:watch": "node --test --enable-source-maps --watch dist/esm/test/*.js",
111
112
  "test": "node --test --enable-source-maps dist/esm/test/*.js"
112
113
  },