Skip to content

Commit 0385cd3

Browse files
LinusUbroofa
andauthoredJun 3, 2024··
feat: add support for MAX uuid (new in RFC9562) (#714)
--------- Co-authored-by: Robert Kieffer <robert@broofa.com>
1 parent f54a866 commit 0385cd3

File tree

16 files changed

+119
-21
lines changed

16 files changed

+119
-21
lines changed
 

‎.github/workflows/browser.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ jobs:
1515
- uses: actions/checkout@v3
1616
with:
1717
fetch-depth: 10
18-
- name: Use Node.js 16.x
18+
- name: Use Node.js 20.x
1919
uses: actions/setup-node@v3
2020
with:
21-
node-version: 16.x
21+
node-version: 20.x
2222
- run: npm ci
2323
- name: Test Browser
2424
run: npm run test:browser

‎README.md

+44-9
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@ For the creation of [RFC4122](https://www.ietf.org/rfc/rfc4122.txt) UUIDs
1818
- **Small** - Zero-dependency, small footprint, plays nice with "tree shaking" packagers
1919
- **CLI** - Includes the [`uuid` command line](#command-line) utility
2020

21-
> **Note** Upgrading from `uuid@3`? Your code is probably okay, but check out [Upgrading From `uuid@3`](#upgrading-from-uuid3) for details.
21+
<!-- prettier-ignore -->
22+
> [!NOTE]
23+
> Upgrading from `uuid@3`? Your code is probably okay, but check out [Upgrading From `uuid@3`](#upgrading-from-uuid3) for details.
2224
23-
> **Note** Only interested in creating a version 4 UUID? You might be able to use [`crypto.randomUUID()`](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID), eliminating the need to install this library.
25+
<!-- prettier-ignore -->
26+
> [!NOTE]
27+
> Only interested in creating a version 4 UUID? You might be able to use [`crypto.randomUUID()`](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID), eliminating the need to install this library.
2428
2529
## Quickstart
2630

@@ -53,6 +57,7 @@ For timestamp UUIDs, namespace UUIDs, and other options read on ...
5357
| | | |
5458
| --- | --- | --- |
5559
| [`uuid.NIL`](#uuidnil) | The nil UUID string (all zeros) | New in `uuid@8.3` |
60+
| [`uuid.MAX`](#uuidmax) | The max UUID string (all ones) | New in `uuid@9.1` |
5661
| [`uuid.parse()`](#uuidparsestr) | Convert UUID string to array of bytes | New in `uuid@8.3` |
5762
| [`uuid.stringify()`](#uuidstringifyarr-offset) | Convert array of bytes to UUID string | New in `uuid@8.3` |
5863
| [`uuid.v1()`](#uuidv1options-buffer-offset) | Create a version 1 (timestamp) UUID | |
@@ -77,6 +82,18 @@ import { NIL as NIL_UUID } from 'uuid';
7782
NIL_UUID; // ⇨ '00000000-0000-0000-0000-000000000000'
7883
```
7984

85+
### uuid.MAX
86+
87+
The max UUID string (all ones).
88+
89+
Example:
90+
91+
```javascript
92+
import { MAX as MAX_UUID } from 'uuid';
93+
94+
MAX_UUID; // ⇨ 'ffffffff-ffff-ffff-ffff-ffffffffffff'
95+
```
96+
8097
### uuid.parse(str)
8198

8299
Convert UUID string to array of bytes
@@ -87,7 +104,9 @@ Convert UUID string to array of bytes
87104
| _returns_ | `Uint8Array[16]` |
88105
| _throws_ | `TypeError` if `str` is not a valid UUID |
89106

90-
Note: Ordering of values in the byte arrays used by `parse()` and `stringify()` follows the left &Rarr; right order of hex-pairs in UUID strings. As shown in the example below.
107+
<!-- prettier-ignore -->
108+
> [!NOTE]
109+
> Ordering of values in the byte arrays used by `parse()` and `stringify()` follows the left &Rarr; right order of hex-pairs in UUID strings. As shown in the example below.
91110
92111
Example:
93112

@@ -118,7 +137,9 @@ Convert array of bytes to UUID string
118137
| _returns_ | `String` |
119138
| _throws_ | `TypeError` if a valid UUID string cannot be generated |
120139

121-
Note: Ordering of values in the byte arrays used by `parse()` and `stringify()` follows the left &Rarr; right order of hex-pairs in UUID strings. As shown in the example below.
140+
<!-- prettier-ignore -->
141+
> [!NOTE]
142+
> Ordering of values in the byte arrays used by `parse()` and `stringify()` follows the left &Rarr; right order of hex-pairs in UUID strings. As shown in the example below.
122143
123144
Example:
124145

@@ -150,9 +171,13 @@ Create an RFC version 1 (timestamp) UUID
150171
| _returns_ | UUID `String` if no `buffer` is specified, otherwise returns `buffer` |
151172
| _throws_ | `Error` if more than 10M UUIDs/sec are requested |
152173

153-
Note: The default [node id](https://tools.ietf.org/html/rfc4122#section-4.1.6) (the last 12 digits in the UUID) is generated once, randomly, on process startup, and then remains unchanged for the duration of the process.
174+
<!-- prettier-ignore -->
175+
> [!NOTE]
176+
> The default [node id](https://tools.ietf.org/html/rfc4122#section-4.1.6) (the last 12 digits in the UUID) is generated once, randomly, on process startup, and then remains unchanged for the duration of the process.
154177
155-
Note: `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.
178+
<!-- prettier-ignore -->
179+
> [!NOTE]
180+
> `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.
156181
157182
Example:
158183

@@ -182,7 +207,9 @@ Create an RFC version 3 (namespace w/ MD5) UUID
182207

183208
API is identical to `v5()`, but uses "v3" instead.
184209

185-
&#x26a0;&#xfe0f; Note: Per the RFC, "_If backward compatibility is not an issue, SHA-1 [Version 5] is preferred_."
210+
<!-- prettier-ignore -->
211+
> [!IMPORTANT]
212+
> Per the RFC, "_If backward compatibility is not an issue, SHA-1 [Version 5] is preferred_."
186213
187214
### uuid.v4([options[, buffer[, offset]]])
188215

@@ -230,7 +257,9 @@ Create an RFC version 5 (namespace w/ SHA-1) UUID
230257
| [`offset` = 0] | `Number` Index to start writing UUID bytes in `buffer` |
231258
| _returns_ | UUID `String` if no `buffer` is specified, otherwise returns `buffer` |
232259

233-
Note: The RFC `DNS` and `URL` namespaces are available as `v5.DNS` and `v5.URL`.
260+
<!-- prettier-ignore -->
261+
> [!NOTE]
262+
> The RFC `DNS` and `URL` namespaces are available as `v5.DNS` and `v5.URL`.
234263
235264
Example with custom namespace:
236265

@@ -329,6 +358,10 @@ uuidVersion('45637ec4-c85f-11ea-87d0-0242ac130003'); // ⇨ 1
329358
uuidVersion('6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b'); // ⇨ 4
330359
```
331360

361+
<!-- prettier-ignore -->
362+
> [!NOTE]
363+
> This method returns `0` for the `NIL` UUID, and `15` for the `MAX` UUID.
364+
332365
## Command Line
333366

334367
UUIDs can be generated from the command line using `uuid`.
@@ -413,7 +446,9 @@ import 'react-native-get-random-values';
413446
import { v4 as uuidv4 } from 'uuid';
414447
```
415448

416-
Note: If you are using Expo, you must be using at least `react-native-get-random-values@1.5.0` and `expo@39.0.0`.
449+
<!-- prettier-ignore -->
450+
> [!NOTE]
451+
> If you are using Expo, you must be using at least `react-native-get-random-values@1.5.0` and `expo@39.0.0`.
417452
418453
### Web Workers / Service Workers (Edge <= 18)
419454

‎README_js.md

+44-9
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,13 @@ For the creation of [RFC4122](https://www.ietf.org/rfc/rfc4122.txt) UUIDs
3232
- **Small** - Zero-dependency, small footprint, plays nice with "tree shaking" packagers
3333
- **CLI** - Includes the [`uuid` command line](#command-line) utility
3434

35-
> **Note** Upgrading from `uuid@3`? Your code is probably okay, but check out [Upgrading From `uuid@3`](#upgrading-from-uuid3) for details.
35+
<!-- prettier-ignore -->
36+
> [!NOTE]
37+
> Upgrading from `uuid@3`? Your code is probably okay, but check out [Upgrading From `uuid@3`](#upgrading-from-uuid3) for details.
3638
37-
> **Note** Only interested in creating a version 4 UUID? You might be able to use [`crypto.randomUUID()`](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID), eliminating the need to install this library.
39+
<!-- prettier-ignore -->
40+
> [!NOTE]
41+
> Only interested in creating a version 4 UUID? You might be able to use [`crypto.randomUUID()`](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID), eliminating the need to install this library.
3842
3943
## Quickstart
4044

@@ -67,6 +71,7 @@ For timestamp UUIDs, namespace UUIDs, and other options read on ...
6771
| | | |
6872
| --- | --- | --- |
6973
| [`uuid.NIL`](#uuidnil) | The nil UUID string (all zeros) | New in `uuid@8.3` |
74+
| [`uuid.MAX`](#uuidmax) | The max UUID string (all ones) | New in `uuid@9.1` |
7075
| [`uuid.parse()`](#uuidparsestr) | Convert UUID string to array of bytes | New in `uuid@8.3` |
7176
| [`uuid.stringify()`](#uuidstringifyarr-offset) | Convert array of bytes to UUID string | New in `uuid@8.3` |
7277
| [`uuid.v1()`](#uuidv1options-buffer-offset) | Create a version 1 (timestamp) UUID | |
@@ -91,6 +96,18 @@ import { NIL as NIL_UUID } from 'uuid';
9196
NIL_UUID; // RESULT
9297
```
9398

99+
### uuid.MAX
100+
101+
The max UUID string (all ones).
102+
103+
Example:
104+
105+
```javascript --run
106+
import { MAX as MAX_UUID } from 'uuid';
107+
108+
MAX_UUID; // RESULT
109+
```
110+
94111
### uuid.parse(str)
95112

96113
Convert UUID string to array of bytes
@@ -101,7 +118,9 @@ Convert UUID string to array of bytes
101118
| _returns_ | `Uint8Array[16]` |
102119
| _throws_ | `TypeError` if `str` is not a valid UUID |
103120

104-
Note: Ordering of values in the byte arrays used by `parse()` and `stringify()` follows the left &Rarr; right order of hex-pairs in UUID strings. As shown in the example below.
121+
<!-- prettier-ignore -->
122+
> [!NOTE]
123+
> Ordering of values in the byte arrays used by `parse()` and `stringify()` follows the left &Rarr; right order of hex-pairs in UUID strings. As shown in the example below.
105124
106125
Example:
107126

@@ -126,7 +145,9 @@ Convert array of bytes to UUID string
126145
| _returns_ | `String` |
127146
| _throws_ | `TypeError` if a valid UUID string cannot be generated |
128147

129-
Note: Ordering of values in the byte arrays used by `parse()` and `stringify()` follows the left &Rarr; right order of hex-pairs in UUID strings. As shown in the example below.
148+
<!-- prettier-ignore -->
149+
> [!NOTE]
150+
> Ordering of values in the byte arrays used by `parse()` and `stringify()` follows the left &Rarr; right order of hex-pairs in UUID strings. As shown in the example below.
130151
131152
Example:
132153

@@ -158,9 +179,13 @@ Create an RFC version 1 (timestamp) UUID
158179
| _returns_ | UUID `String` if no `buffer` is specified, otherwise returns `buffer` |
159180
| _throws_ | `Error` if more than 10M UUIDs/sec are requested |
160181

161-
Note: The default [node id](https://tools.ietf.org/html/rfc4122#section-4.1.6) (the last 12 digits in the UUID) is generated once, randomly, on process startup, and then remains unchanged for the duration of the process.
182+
<!-- prettier-ignore -->
183+
> [!NOTE]
184+
> The default [node id](https://tools.ietf.org/html/rfc4122#section-4.1.6) (the last 12 digits in the UUID) is generated once, randomly, on process startup, and then remains unchanged for the duration of the process.
162185
163-
Note: `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.
186+
<!-- prettier-ignore -->
187+
> [!NOTE]
188+
> `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.
164189
165190
Example:
166191

@@ -190,7 +215,9 @@ Create an RFC version 3 (namespace w/ MD5) UUID
190215

191216
API is identical to `v5()`, but uses "v3" instead.
192217

193-
&#x26a0;&#xfe0f; Note: Per the RFC, "_If backward compatibility is not an issue, SHA-1 [Version 5] is preferred_."
218+
<!-- prettier-ignore -->
219+
> [!IMPORTANT]
220+
> Per the RFC, "_If backward compatibility is not an issue, SHA-1 [Version 5] is preferred_."
194221
195222
### uuid.v4([options[, buffer[, offset]]])
196223

@@ -238,7 +265,9 @@ Create an RFC version 5 (namespace w/ SHA-1) UUID
238265
| [`offset` = 0] | `Number` Index to start writing UUID bytes in `buffer` |
239266
| _returns_ | UUID `String` if no `buffer` is specified, otherwise returns `buffer` |
240267

241-
Note: The RFC `DNS` and `URL` namespaces are available as `v5.DNS` and `v5.URL`.
268+
<!-- prettier-ignore -->
269+
> [!NOTE]
270+
> The RFC `DNS` and `URL` namespaces are available as `v5.DNS` and `v5.URL`.
242271
243272
Example with custom namespace:
244273

@@ -337,6 +366,10 @@ uuidVersion('45637ec4-c85f-11ea-87d0-0242ac130003'); // RESULT
337366
uuidVersion('6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b'); // RESULT
338367
```
339368

369+
<!-- prettier-ignore -->
370+
> [!NOTE]
371+
> This method returns `0` for the `NIL` UUID, and `15` for the `MAX` UUID.
372+
340373
## Command Line
341374

342375
UUIDs can be generated from the command line using `uuid`.
@@ -421,7 +454,9 @@ import 'react-native-get-random-values';
421454
import { v4 as uuidv4 } from 'uuid';
422455
```
423456

424-
Note: If you are using Expo, you must be using at least `react-native-get-random-values@1.5.0` and `expo@39.0.0`.
457+
<!-- prettier-ignore -->
458+
> [!NOTE]
459+
> If you are using Expo, you must be using at least `react-native-get-random-values@1.5.0` and `expo@39.0.0`.
425460
426461
### Web Workers / Service Workers (Edge <= 18)
427462

‎examples/browser-esmodules/example.js

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
NIL as NIL_UUID,
3+
MAX as MAX_UUID,
34
parse as uuidParse,
45
stringify as uuidStringify,
56
v1 as uuidv1,
@@ -46,6 +47,7 @@ console.log('uuidv5() MY_NAMESPACE', uuidv5('Hello, World!', MY_NAMESPACE));
4647

4748
// Utility functions
4849
console.log('NIL_UUID', NIL_UUID);
50+
console.log('MAX_UUID', MAX_UUID);
4951
console.log('uuidParse()', uuidParse(MY_NAMESPACE));
5052
console.log('uuidStringify()', uuidStringify(uuidParse(MY_NAMESPACE)));
5153
console.log('uuidValidate()', uuidValidate(MY_NAMESPACE));
@@ -64,6 +66,7 @@ console.log('uuid.v5() URL', uuid.v5('http://example.com/hello', uuid.v5.URL));
6466
console.log('uuid.v5() MY_NAMESPACE', uuid.v5('Hello, World!', MY_NAMESPACE));
6567

6668
console.log('uuid.NIL', uuid.NIL);
69+
console.log('uuid.MAX', uuid.MAX);
6770
console.log('uuid.parse()', uuid.parse(MY_NAMESPACE));
6871
console.log('uuid.stringify()', uuid.stringify(uuid.parse(MY_NAMESPACE)));
6972
console.log('uuid.validate()', uuid.validate(MY_NAMESPACE));

‎examples/browser-rollup/example-all.js

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
NIL as NIL_UUID,
3+
MAX as MAX_UUID,
34
parse as uuidParse,
45
stringify as uuidStringify,
56
v1 as uuidv1,
@@ -51,6 +52,7 @@ testpage(function (addTest, done) {
5152

5253
// Utility functions
5354
addTest('NIL_UUID', NIL_UUID);
55+
addTest('MAX_UUID', MAX_UUID);
5456
addTest('uuidParse()', uuidParse(MY_NAMESPACE));
5557
addTest('uuidStringify()', uuidStringify(uuidParse(MY_NAMESPACE)));
5658
addTest('uuidValidate()', uuidValidate(MY_NAMESPACE));
@@ -69,6 +71,7 @@ testpage(function (addTest, done) {
6971
addTest('uuid.v5() MY_NAMESPACE', uuid.v5('Hello, World!', MY_NAMESPACE));
7072

7173
addTest('uuid.NIL', uuid.NIL);
74+
addTest('uuid.MAX', uuid.MAX);
7275
addTest('uuid.parse()', uuid.parse(MY_NAMESPACE));
7376
addTest('uuid.stringify()', uuid.stringify(uuid.parse(MY_NAMESPACE)));
7477
addTest('uuid.validate()', uuid.validate(MY_NAMESPACE));

‎examples/browser-webpack/example-all-require.js

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const uuid = require('uuid');
22
const {
33
NIL: NIL_UUID,
4+
MAX: MAX_UUID,
45
parse: uuidParse,
56
stringify: uuidStringify,
67
v1: uuidv1,
@@ -51,6 +52,7 @@ testpage(function (addTest, done) {
5152

5253
// Utility functions
5354
addTest('NIL_UUID', NIL_UUID);
55+
addTest('MAX_UUID', MAX_UUID);
5456
addTest('uuidParse()', uuidParse(MY_NAMESPACE));
5557
addTest('uuidStringify()', uuidStringify(uuidParse(MY_NAMESPACE)));
5658
addTest('uuidValidate()', uuidValidate(MY_NAMESPACE));
@@ -69,6 +71,7 @@ testpage(function (addTest, done) {
6971
addTest('uuid.v5() MY_NAMESPACE', uuid.v5('Hello, World!', MY_NAMESPACE));
7072

7173
addTest('uuid.NIL', uuid.NIL);
74+
addTest('uuid.MAX', uuid.MAX);
7275
addTest('uuid.parse()', uuid.parse(MY_NAMESPACE));
7376
addTest('uuid.stringify()', uuid.stringify(uuid.parse(MY_NAMESPACE)));
7477
addTest('uuid.validate()', uuid.validate(MY_NAMESPACE));

‎examples/browser-webpack/example-all.js

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
NIL as NIL_UUID,
3+
MAX as MAX_UUID,
34
parse as uuidParse,
45
stringify as uuidStringify,
56
v1 as uuidv1,
@@ -51,6 +52,7 @@ testpage(function (addTest, done) {
5152

5253
// Utility functions
5354
addTest('NIL_UUID', NIL_UUID);
55+
addTest('MAX_UUID', MAX_UUID);
5456
addTest('uuidParse()', uuidParse(MY_NAMESPACE));
5557
addTest('uuidStringify()', uuidStringify(uuidParse(MY_NAMESPACE)));
5658
addTest('uuidValidate()', uuidValidate(MY_NAMESPACE));
@@ -69,6 +71,7 @@ testpage(function (addTest, done) {
6971
addTest('uuid.v5() MY_NAMESPACE', uuid.v5('Hello, World!', MY_NAMESPACE));
7072

7173
addTest('uuid.NIL', uuid.NIL);
74+
addTest('uuid.MAX', uuid.MAX);
7275
addTest('uuid.parse()', uuid.parse(MY_NAMESPACE));
7376
addTest('uuid.stringify()', uuid.stringify(uuid.parse(MY_NAMESPACE)));
7477
addTest('uuid.validate()', uuid.validate(MY_NAMESPACE));

‎examples/node-commonjs/example.js

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const {
22
NIL: NIL_UUID,
3+
MAX: MAX_UUID,
34
parse: uuidParse,
45
stringify: uuidStringify,
56
v1: uuidv1,
@@ -47,6 +48,7 @@ console.log('uuidv5() MY_NAMESPACE', uuidv5('Hello, World!', MY_NAMESPACE));
4748

4849
// Utility functions
4950
console.log('NIL_UUID', NIL_UUID);
51+
console.log('MAX_UUID', MAX_UUID);
5052
console.log('uuidParse()', uuidParse(MY_NAMESPACE));
5153
console.log('uuidStringify()', uuidStringify(uuidParse(MY_NAMESPACE)));
5254
console.log('uuidValidate()', uuidValidate(MY_NAMESPACE));
@@ -65,6 +67,7 @@ console.log('uuid.v5() URL', uuid.v5('http://example.com/hello', uuid.v5.URL));
6567
console.log('uuid.v5() MY_NAMESPACE', uuid.v5('Hello, World!', MY_NAMESPACE));
6668

6769
console.log('uuid.NIL', uuid.NIL);
70+
console.log('uuid.MAX', uuid.MAX);
6871
console.log('uuid.parse()', uuid.parse(MY_NAMESPACE));
6972
console.log('uuid.stringify()', uuid.stringify(uuid.parse(MY_NAMESPACE)));
7073
console.log('uuid.validate()', uuid.validate(MY_NAMESPACE));

‎examples/node-esmodules/example.mjs

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
NIL as NIL_UUID,
3+
MAX as MAX_UUID,
34
parse as uuidParse,
45
stringify as uuidStringify,
56
v1 as uuidv1,
@@ -46,6 +47,7 @@ console.log('uuidv5() MY_NAMESPACE', uuidv5('Hello, World!', MY_NAMESPACE));
4647

4748
// Utility functions
4849
console.log('NIL_UUID', NIL_UUID);
50+
console.log('MAX_UUID', MAX_UUID);
4951
console.log('uuidParse()', uuidParse(MY_NAMESPACE));
5052
console.log('uuidStringify()', uuidStringify(uuidParse(MY_NAMESPACE)));
5153
console.log('uuidValidate()', uuidValidate(MY_NAMESPACE));
@@ -64,6 +66,7 @@ console.log('uuid.v5() URL', uuid.v5('http://example.com/hello', uuid.v5.URL));
6466
console.log('uuid.v5() MY_NAMESPACE', uuid.v5('Hello, World!', MY_NAMESPACE));
6567

6668
console.log('uuid.NIL', uuid.NIL);
69+
console.log('uuid.MAX', uuid.MAX);
6770
console.log('uuid.parse()', uuid.parse(MY_NAMESPACE));
6871
console.log('uuid.stringify()', uuid.stringify(uuid.parse(MY_NAMESPACE)));
6972
console.log('uuid.validate()', uuid.validate(MY_NAMESPACE));

‎src/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export { default as v4 } from './v4.js';
44
export { default as v5 } from './v5.js';
55
export { default as v7 } from './v7.js';
66
export { default as NIL } from './nil.js';
7+
export { default as MAX } from './max.js';
78
export { default as version } from './version.js';
89
export { default as validate } from './validate.js';
910
export { default as stringify } from './stringify.js';

‎src/max.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default 'ffffffff-ffff-ffff-ffff-ffffffffffff';

‎src/regex.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export default /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
1+
export default /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;

‎test/browser/browser.spec.js

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const v5url = (result) => expect(result).toBe('3bbcee75-cecc-5b56-8031-b6641c1ed
1515
const v5custom = (result) => expect(result).toBe('c49c5142-4d9a-5940-a926-612ede0ec632');
1616

1717
const nil = (result) => expect(result).toBe('00000000-0000-0000-0000-000000000000');
18+
const max = (result) => expect(result).toBe('ffffffff-ffff-ffff-ffff-ffffffffffff');
1819
const parse = (result) =>
1920
expect(result).toEqual('85,35,141,21,201,38,69,152,180,157,207,78,145,59,161,60');
2021
const stringify = (result) => expect(result).toBe('55238d15-c926-4598-b49d-cf4e913ba13c');
@@ -33,6 +34,7 @@ const expectations = {
3334
'uuidv5() MY_NAMESPACE': v5custom,
3435

3536
NIL_UUID: nil,
37+
MAX_UUID: max,
3638
'uuidParse()': parse,
3739
'uuidStringify()': stringify,
3840
'uuidValidate()': validate,
@@ -49,6 +51,7 @@ const expectations = {
4951
'uuid.v5() MY_NAMESPACE': v5custom,
5052

5153
'uuid.NIL': nil,
54+
'uuid.MAX': max,
5255
'uuid.parse()': parse,
5356
'uuid.stringify()': stringify,
5457
'uuid.validate()': validate,

‎test/unit/validate.test.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import assert from 'assert';
22
import validate from '../../src/validate.js';
33
import NIL from '../../src/nil.js';
4+
import MAX from '../../src/max.js';
45

56
describe('validate', () => {
67
test('validate uuid', () => {
78
assert.strictEqual(validate(NIL), true);
9+
assert.strictEqual(validate(MAX), true);
810

911
// test valid UUID versions
1012

‎test/unit/version.test.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import assert from 'assert';
22
import version from '../../src/version.js';
33
import NIL from '../../src/nil.js';
4+
import MAX from '../../src/max.js';
45

56
describe('version', () => {
67
test('check uuid version', () => {
78
assert.strictEqual(version(NIL), 0);
9+
assert.strictEqual(version(MAX), 15);
810

911
assert.strictEqual(version('d9428888-122b-11e1-b85c-61cd3cbb3210'), 1);
1012

‎wrapper.mjs

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export const v4 = uuid.v4;
55
export const v5 = uuid.v5;
66
export const v7 = uuid.v7;
77
export const NIL = uuid.NIL;
8+
export const MAX = uuid.MAX;
89
export const version = uuid.version;
910
export const validate = uuid.validate;
1011
export const stringify = uuid.stringify;

0 commit comments

Comments
 (0)
Please sign in to comment.