uuid 11.0.5 → 11.1.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 +12 -12
- package/dist/cjs/types.d.ts +1 -1
- package/dist/cjs/v1.d.ts +1 -1
- package/dist/cjs/v1.js +1 -1
- package/dist/cjs/v3.d.ts +1 -1
- package/dist/cjs/v35.d.ts +1 -1
- package/dist/cjs/v35.js +3 -0
- package/dist/cjs/v4.d.ts +1 -1
- package/dist/cjs/v5.d.ts +1 -1
- package/dist/cjs/v6.d.ts +1 -1
- package/dist/cjs/v6.js +3 -0
- package/dist/cjs/v7.d.ts +1 -1
- package/dist/cjs/v7.js +1 -1
- package/dist/cjs-browser/types.d.ts +1 -1
- package/dist/cjs-browser/v1.d.ts +1 -1
- package/dist/cjs-browser/v1.js +1 -1
- package/dist/cjs-browser/v3.d.ts +1 -1
- package/dist/cjs-browser/v35.d.ts +1 -1
- package/dist/cjs-browser/v35.js +3 -0
- package/dist/cjs-browser/v4.d.ts +1 -1
- package/dist/cjs-browser/v5.d.ts +1 -1
- package/dist/cjs-browser/v6.d.ts +1 -1
- package/dist/cjs-browser/v6.js +3 -0
- package/dist/cjs-browser/v7.d.ts +1 -1
- package/dist/cjs-browser/v7.js +1 -1
- package/dist/esm/types.d.ts +1 -1
- package/dist/esm/v1.d.ts +1 -1
- package/dist/esm/v1.js +1 -1
- package/dist/esm/v3.d.ts +1 -1
- package/dist/esm/v35.d.ts +1 -1
- package/dist/esm/v35.js +3 -0
- package/dist/esm/v4.d.ts +1 -1
- package/dist/esm/v5.d.ts +1 -1
- package/dist/esm/v6.d.ts +1 -1
- package/dist/esm/v6.js +3 -0
- package/dist/esm/v7.d.ts +1 -1
- package/dist/esm/v7.js +1 -1
- package/dist/esm-browser/types.d.ts +1 -1
- package/dist/esm-browser/v1.d.ts +1 -1
- package/dist/esm-browser/v1.js +1 -1
- package/dist/esm-browser/v3.d.ts +1 -1
- package/dist/esm-browser/v35.d.ts +1 -1
- package/dist/esm-browser/v35.js +3 -0
- package/dist/esm-browser/v4.d.ts +1 -1
- package/dist/esm-browser/v5.d.ts +1 -1
- package/dist/esm-browser/v6.d.ts +1 -1
- package/dist/esm-browser/v6.js +3 -0
- package/dist/esm-browser/v7.d.ts +1 -1
- package/dist/esm-browser/v7.js +1 -1
- package/package.json +1 -1
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 [](https://github.com/uuidjs/uuid/actions?query=workflow%3ACI) [](https://github.com/uuidjs/uuid/actions
|
|
5
|
+
# uuid [](https://github.com/uuidjs/uuid/actions?query=workflow%3ACI) [](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) (
|
|
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
|
-
- [
|
|
12
|
+
- [Typescript](#support)
|
|
13
|
+
- [Chrome, Safari, Firefox, and Edge](#support)
|
|
13
14
|
- [NodeJS](#support)
|
|
14
15
|
- [React Native / Expo](#react-native--expo)
|
|
15
|
-
- **Secure** -
|
|
16
|
-
- **Compact** -
|
|
17
|
-
- **CLI** -
|
|
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
|
-
|
|
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`] | `
|
|
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`] | `
|
|
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`] | `
|
|
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`] | `
|
|
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/types.d.ts
CHANGED
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:
|
|
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
|
@@ -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
|
|
25
|
+
return buf ?? (0, stringify_js_1.unsafeStringify)(bytes);
|
|
26
26
|
}
|
|
27
27
|
function updateV1State(state, now, rnds) {
|
|
28
28
|
state.msecs ??= -Infinity;
|
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:
|
|
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
|
@@ -3,5 +3,5 @@ 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?:
|
|
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
|
@@ -31,6 +31,9 @@ function v35(version, hash, value, namespace, buf, offset) {
|
|
|
31
31
|
bytes[8] = (bytes[8] & 0x3f) | 0x80;
|
|
32
32
|
if (buf) {
|
|
33
33
|
offset = offset || 0;
|
|
34
|
+
if (offset < 0 || offset + 16 > buf.length) {
|
|
35
|
+
throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
|
|
36
|
+
}
|
|
34
37
|
for (let i = 0; i < 16; ++i) {
|
|
35
38
|
buf[offset + i] = bytes[i];
|
|
36
39
|
}
|
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:
|
|
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:
|
|
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:
|
|
3
|
+
declare function v6<TBuf extends Uint8Array = Uint8Array>(options: Version6Options | undefined, buf: TBuf, offset?: number): TBuf;
|
|
4
4
|
export default v6;
|
package/dist/cjs/v6.js
CHANGED
|
@@ -9,6 +9,9 @@ function v6(options, buf, offset) {
|
|
|
9
9
|
let bytes = (0, v1_js_1.default)({ ...options, _v6: true }, new Uint8Array(16));
|
|
10
10
|
bytes = (0, v1ToV6_js_1.default)(bytes);
|
|
11
11
|
if (buf) {
|
|
12
|
+
if (offset < 0 || offset + 16 > buf.length) {
|
|
13
|
+
throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
|
|
14
|
+
}
|
|
12
15
|
for (let i = 0; i < 16; i++) {
|
|
13
16
|
buf[offset + i] = bytes[i];
|
|
14
17
|
}
|
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:
|
|
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
|
@@ -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
|
|
18
|
+
return buf ?? (0, stringify_js_1.unsafeStringify)(bytes);
|
|
19
19
|
}
|
|
20
20
|
function updateV7State(state, now, rnds) {
|
|
21
21
|
state.msecs ??= -Infinity;
|
package/dist/cjs-browser/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:
|
|
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-browser/v1.js
CHANGED
|
@@ -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
|
|
25
|
+
return buf ?? (0, stringify_js_1.unsafeStringify)(bytes);
|
|
26
26
|
}
|
|
27
27
|
function updateV1State(state, now, rnds) {
|
|
28
28
|
state.msecs ??= -Infinity;
|
package/dist/cjs-browser/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:
|
|
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;
|
|
@@ -3,5 +3,5 @@ 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?:
|
|
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-browser/v35.js
CHANGED
|
@@ -31,6 +31,9 @@ function v35(version, hash, value, namespace, buf, offset) {
|
|
|
31
31
|
bytes[8] = (bytes[8] & 0x3f) | 0x80;
|
|
32
32
|
if (buf) {
|
|
33
33
|
offset = offset || 0;
|
|
34
|
+
if (offset < 0 || offset + 16 > buf.length) {
|
|
35
|
+
throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
|
|
36
|
+
}
|
|
34
37
|
for (let i = 0; i < 16; ++i) {
|
|
35
38
|
buf[offset + i] = bytes[i];
|
|
36
39
|
}
|
package/dist/cjs-browser/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:
|
|
3
|
+
declare function v4<TBuf extends Uint8Array = Uint8Array>(options: Version4Options | undefined, buf: TBuf, offset?: number): TBuf;
|
|
4
4
|
export default v4;
|
package/dist/cjs-browser/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:
|
|
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-browser/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:
|
|
3
|
+
declare function v6<TBuf extends Uint8Array = Uint8Array>(options: Version6Options | undefined, buf: TBuf, offset?: number): TBuf;
|
|
4
4
|
export default v6;
|
package/dist/cjs-browser/v6.js
CHANGED
|
@@ -9,6 +9,9 @@ function v6(options, buf, offset) {
|
|
|
9
9
|
let bytes = (0, v1_js_1.default)({ ...options, _v6: true }, new Uint8Array(16));
|
|
10
10
|
bytes = (0, v1ToV6_js_1.default)(bytes);
|
|
11
11
|
if (buf) {
|
|
12
|
+
if (offset < 0 || offset + 16 > buf.length) {
|
|
13
|
+
throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
|
|
14
|
+
}
|
|
12
15
|
for (let i = 0; i < 16; i++) {
|
|
13
16
|
buf[offset + i] = bytes[i];
|
|
14
17
|
}
|
package/dist/cjs-browser/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:
|
|
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-browser/v7.js
CHANGED
|
@@ -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
|
|
18
|
+
return buf ?? (0, stringify_js_1.unsafeStringify)(bytes);
|
|
19
19
|
}
|
|
20
20
|
function updateV7State(state, now, rnds) {
|
|
21
21
|
state.msecs ??= -Infinity;
|
package/dist/esm/types.d.ts
CHANGED
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:
|
|
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
|
|
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:
|
|
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
|
@@ -3,5 +3,5 @@ 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?:
|
|
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/v35.js
CHANGED
|
@@ -27,6 +27,9 @@ export default function v35(version, hash, value, namespace, buf, offset) {
|
|
|
27
27
|
bytes[8] = (bytes[8] & 0x3f) | 0x80;
|
|
28
28
|
if (buf) {
|
|
29
29
|
offset = offset || 0;
|
|
30
|
+
if (offset < 0 || offset + 16 > buf.length) {
|
|
31
|
+
throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
|
|
32
|
+
}
|
|
30
33
|
for (let i = 0; i < 16; ++i) {
|
|
31
34
|
buf[offset + i] = bytes[i];
|
|
32
35
|
}
|
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:
|
|
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:
|
|
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:
|
|
3
|
+
declare function v6<TBuf extends Uint8Array = Uint8Array>(options: Version6Options | undefined, buf: TBuf, offset?: number): TBuf;
|
|
4
4
|
export default v6;
|
package/dist/esm/v6.js
CHANGED
|
@@ -7,6 +7,9 @@ function v6(options, buf, offset) {
|
|
|
7
7
|
let bytes = v1({ ...options, _v6: true }, new Uint8Array(16));
|
|
8
8
|
bytes = v1ToV6(bytes);
|
|
9
9
|
if (buf) {
|
|
10
|
+
if (offset < 0 || offset + 16 > buf.length) {
|
|
11
|
+
throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
|
|
12
|
+
}
|
|
10
13
|
for (let i = 0; i < 16; i++) {
|
|
11
14
|
buf[offset + i] = bytes[i];
|
|
12
15
|
}
|
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:
|
|
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
|
|
15
|
+
return buf ?? unsafeStringify(bytes);
|
|
16
16
|
}
|
|
17
17
|
export function updateV7State(state, now, rnds) {
|
|
18
18
|
state.msecs ??= -Infinity;
|
package/dist/esm-browser/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:
|
|
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-browser/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
|
|
22
|
+
return buf ?? unsafeStringify(bytes);
|
|
23
23
|
}
|
|
24
24
|
export function updateV1State(state, now, rnds) {
|
|
25
25
|
state.msecs ??= -Infinity;
|
package/dist/esm-browser/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:
|
|
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;
|
|
@@ -3,5 +3,5 @@ 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?:
|
|
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-browser/v35.js
CHANGED
|
@@ -27,6 +27,9 @@ export default function v35(version, hash, value, namespace, buf, offset) {
|
|
|
27
27
|
bytes[8] = (bytes[8] & 0x3f) | 0x80;
|
|
28
28
|
if (buf) {
|
|
29
29
|
offset = offset || 0;
|
|
30
|
+
if (offset < 0 || offset + 16 > buf.length) {
|
|
31
|
+
throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
|
|
32
|
+
}
|
|
30
33
|
for (let i = 0; i < 16; ++i) {
|
|
31
34
|
buf[offset + i] = bytes[i];
|
|
32
35
|
}
|
package/dist/esm-browser/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:
|
|
3
|
+
declare function v4<TBuf extends Uint8Array = Uint8Array>(options: Version4Options | undefined, buf: TBuf, offset?: number): TBuf;
|
|
4
4
|
export default v4;
|
package/dist/esm-browser/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:
|
|
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-browser/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:
|
|
3
|
+
declare function v6<TBuf extends Uint8Array = Uint8Array>(options: Version6Options | undefined, buf: TBuf, offset?: number): TBuf;
|
|
4
4
|
export default v6;
|
package/dist/esm-browser/v6.js
CHANGED
|
@@ -7,6 +7,9 @@ function v6(options, buf, offset) {
|
|
|
7
7
|
let bytes = v1({ ...options, _v6: true }, new Uint8Array(16));
|
|
8
8
|
bytes = v1ToV6(bytes);
|
|
9
9
|
if (buf) {
|
|
10
|
+
if (offset < 0 || offset + 16 > buf.length) {
|
|
11
|
+
throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
|
|
12
|
+
}
|
|
10
13
|
for (let i = 0; i < 16; i++) {
|
|
11
14
|
buf[offset + i] = bytes[i];
|
|
12
15
|
}
|
package/dist/esm-browser/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:
|
|
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-browser/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
|
|
15
|
+
return buf ?? unsafeStringify(bytes);
|
|
16
16
|
}
|
|
17
17
|
export function updateV7State(state, now, rnds) {
|
|
18
18
|
state.msecs ??= -Infinity;
|