From 0385cd3f18ae9920678b2849932fa7a9d9aee7d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Mon, 3 Jun 2024 07:56:49 +0200 Subject: [PATCH] feat: add support for MAX uuid (new in RFC9562) (#714) --------- Co-authored-by: Robert Kieffer --- .github/workflows/browser.yml | 4 +- README.md | 53 +++++++++++++++---- README_js.md | 53 +++++++++++++++---- examples/browser-esmodules/example.js | 3 ++ examples/browser-rollup/example-all.js | 3 ++ .../browser-webpack/example-all-require.js | 3 ++ examples/browser-webpack/example-all.js | 3 ++ examples/node-commonjs/example.js | 3 ++ examples/node-esmodules/example.mjs | 3 ++ src/index.js | 1 + src/max.js | 1 + src/regex.js | 2 +- test/browser/browser.spec.js | 3 ++ test/unit/validate.test.js | 2 + test/unit/version.test.js | 2 + wrapper.mjs | 1 + 16 files changed, 119 insertions(+), 21 deletions(-) create mode 100644 src/max.js diff --git a/.github/workflows/browser.yml b/.github/workflows/browser.yml index 77713d18..66a6a12b 100644 --- a/.github/workflows/browser.yml +++ b/.github/workflows/browser.yml @@ -15,10 +15,10 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 10 - - name: Use Node.js 16.x + - name: Use Node.js 20.x uses: actions/setup-node@v3 with: - node-version: 16.x + node-version: 20.x - run: npm ci - name: Test Browser run: npm run test:browser diff --git a/README.md b/README.md index 816ece0f..742c6877 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,13 @@ For the creation of [RFC4122](https://www.ietf.org/rfc/rfc4122.txt) UUIDs - **Small** - Zero-dependency, small footprint, plays nice with "tree shaking" packagers - **CLI** - Includes the [`uuid` command line](#command-line) utility -> **Note** Upgrading from `uuid@3`? Your code is probably okay, but check out [Upgrading From `uuid@3`](#upgrading-from-uuid3) for details. + +> [!NOTE] +> Upgrading from `uuid@3`? Your code is probably okay, but check out [Upgrading From `uuid@3`](#upgrading-from-uuid3) for details. -> **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. + +> [!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. ## Quickstart @@ -53,6 +57,7 @@ For timestamp UUIDs, namespace UUIDs, and other options read on ... | | | | | --- | --- | --- | | [`uuid.NIL`](#uuidnil) | The nil UUID string (all zeros) | New in `uuid@8.3` | +| [`uuid.MAX`](#uuidmax) | The max UUID string (all ones) | New in `uuid@9.1` | | [`uuid.parse()`](#uuidparsestr) | Convert UUID string to array of bytes | New in `uuid@8.3` | | [`uuid.stringify()`](#uuidstringifyarr-offset) | Convert array of bytes to UUID string | New in `uuid@8.3` | | [`uuid.v1()`](#uuidv1options-buffer-offset) | Create a version 1 (timestamp) UUID | | @@ -77,6 +82,18 @@ import { NIL as NIL_UUID } from 'uuid'; NIL_UUID; // ⇨ '00000000-0000-0000-0000-000000000000' ``` +### uuid.MAX + +The max UUID string (all ones). + +Example: + +```javascript +import { MAX as MAX_UUID } from 'uuid'; + +MAX_UUID; // ⇨ 'ffffffff-ffff-ffff-ffff-ffffffffffff' +``` + ### uuid.parse(str) Convert UUID string to array of bytes @@ -87,7 +104,9 @@ Convert UUID string to array of bytes | _returns_ | `Uint8Array[16]` | | _throws_ | `TypeError` if `str` is not a valid UUID | -Note: Ordering of values in the byte arrays used by `parse()` and `stringify()` follows the left ↠ right order of hex-pairs in UUID strings. As shown in the example below. + +> [!NOTE] +> Ordering of values in the byte arrays used by `parse()` and `stringify()` follows the left ↠ right order of hex-pairs in UUID strings. As shown in the example below. Example: @@ -118,7 +137,9 @@ Convert array of bytes to UUID string | _returns_ | `String` | | _throws_ | `TypeError` if a valid UUID string cannot be generated | -Note: Ordering of values in the byte arrays used by `parse()` and `stringify()` follows the left ↠ right order of hex-pairs in UUID strings. As shown in the example below. + +> [!NOTE] +> Ordering of values in the byte arrays used by `parse()` and `stringify()` follows the left ↠ right order of hex-pairs in UUID strings. As shown in the example below. Example: @@ -150,9 +171,13 @@ Create an RFC version 1 (timestamp) UUID | _returns_ | UUID `String` if no `buffer` is specified, otherwise returns `buffer` | | _throws_ | `Error` if more than 10M UUIDs/sec are requested | -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. + +> [!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. -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. + +> [!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. Example: @@ -182,7 +207,9 @@ Create an RFC version 3 (namespace w/ MD5) UUID API is identical to `v5()`, but uses "v3" instead. -⚠️ Note: Per the RFC, "_If backward compatibility is not an issue, SHA-1 [Version 5] is preferred_." + +> [!IMPORTANT] +> Per the RFC, "_If backward compatibility is not an issue, SHA-1 [Version 5] is preferred_." ### uuid.v4([options[, buffer[, offset]]]) @@ -230,7 +257,9 @@ Create an RFC version 5 (namespace w/ SHA-1) UUID | [`offset` = 0] | `Number` Index to start writing UUID bytes in `buffer` | | _returns_ | UUID `String` if no `buffer` is specified, otherwise returns `buffer` | -Note: The RFC `DNS` and `URL` namespaces are available as `v5.DNS` and `v5.URL`. + +> [!NOTE] +> The RFC `DNS` and `URL` namespaces are available as `v5.DNS` and `v5.URL`. Example with custom namespace: @@ -329,6 +358,10 @@ uuidVersion('45637ec4-c85f-11ea-87d0-0242ac130003'); // ⇨ 1 uuidVersion('6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b'); // ⇨ 4 ``` + +> [!NOTE] +> This method returns `0` for the `NIL` UUID, and `15` for the `MAX` UUID. + ## Command Line UUIDs can be generated from the command line using `uuid`. @@ -413,7 +446,9 @@ import 'react-native-get-random-values'; import { v4 as uuidv4 } from 'uuid'; ``` -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`. + +> [!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`. ### Web Workers / Service Workers (Edge <= 18) diff --git a/README_js.md b/README_js.md index 88c0c3dd..86595e2a 100644 --- a/README_js.md +++ b/README_js.md @@ -32,9 +32,13 @@ For the creation of [RFC4122](https://www.ietf.org/rfc/rfc4122.txt) UUIDs - **Small** - Zero-dependency, small footprint, plays nice with "tree shaking" packagers - **CLI** - Includes the [`uuid` command line](#command-line) utility -> **Note** Upgrading from `uuid@3`? Your code is probably okay, but check out [Upgrading From `uuid@3`](#upgrading-from-uuid3) for details. + +> [!NOTE] +> Upgrading from `uuid@3`? Your code is probably okay, but check out [Upgrading From `uuid@3`](#upgrading-from-uuid3) for details. -> **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. + +> [!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. ## Quickstart @@ -67,6 +71,7 @@ For timestamp UUIDs, namespace UUIDs, and other options read on ... | | | | | --- | --- | --- | | [`uuid.NIL`](#uuidnil) | The nil UUID string (all zeros) | New in `uuid@8.3` | +| [`uuid.MAX`](#uuidmax) | The max UUID string (all ones) | New in `uuid@9.1` | | [`uuid.parse()`](#uuidparsestr) | Convert UUID string to array of bytes | New in `uuid@8.3` | | [`uuid.stringify()`](#uuidstringifyarr-offset) | Convert array of bytes to UUID string | New in `uuid@8.3` | | [`uuid.v1()`](#uuidv1options-buffer-offset) | Create a version 1 (timestamp) UUID | | @@ -91,6 +96,18 @@ import { NIL as NIL_UUID } from 'uuid'; NIL_UUID; // RESULT ``` +### uuid.MAX + +The max UUID string (all ones). + +Example: + +```javascript --run +import { MAX as MAX_UUID } from 'uuid'; + +MAX_UUID; // RESULT +``` + ### uuid.parse(str) Convert UUID string to array of bytes @@ -101,7 +118,9 @@ Convert UUID string to array of bytes | _returns_ | `Uint8Array[16]` | | _throws_ | `TypeError` if `str` is not a valid UUID | -Note: Ordering of values in the byte arrays used by `parse()` and `stringify()` follows the left ↠ right order of hex-pairs in UUID strings. As shown in the example below. + +> [!NOTE] +> Ordering of values in the byte arrays used by `parse()` and `stringify()` follows the left ↠ right order of hex-pairs in UUID strings. As shown in the example below. Example: @@ -126,7 +145,9 @@ Convert array of bytes to UUID string | _returns_ | `String` | | _throws_ | `TypeError` if a valid UUID string cannot be generated | -Note: Ordering of values in the byte arrays used by `parse()` and `stringify()` follows the left ↠ right order of hex-pairs in UUID strings. As shown in the example below. + +> [!NOTE] +> Ordering of values in the byte arrays used by `parse()` and `stringify()` follows the left ↠ right order of hex-pairs in UUID strings. As shown in the example below. Example: @@ -158,9 +179,13 @@ Create an RFC version 1 (timestamp) UUID | _returns_ | UUID `String` if no `buffer` is specified, otherwise returns `buffer` | | _throws_ | `Error` if more than 10M UUIDs/sec are requested | -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. + +> [!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. -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. + +> [!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. Example: @@ -190,7 +215,9 @@ Create an RFC version 3 (namespace w/ MD5) UUID API is identical to `v5()`, but uses "v3" instead. -⚠️ Note: Per the RFC, "_If backward compatibility is not an issue, SHA-1 [Version 5] is preferred_." + +> [!IMPORTANT] +> Per the RFC, "_If backward compatibility is not an issue, SHA-1 [Version 5] is preferred_." ### uuid.v4([options[, buffer[, offset]]]) @@ -238,7 +265,9 @@ Create an RFC version 5 (namespace w/ SHA-1) UUID | [`offset` = 0] | `Number` Index to start writing UUID bytes in `buffer` | | _returns_ | UUID `String` if no `buffer` is specified, otherwise returns `buffer` | -Note: The RFC `DNS` and `URL` namespaces are available as `v5.DNS` and `v5.URL`. + +> [!NOTE] +> The RFC `DNS` and `URL` namespaces are available as `v5.DNS` and `v5.URL`. Example with custom namespace: @@ -337,6 +366,10 @@ uuidVersion('45637ec4-c85f-11ea-87d0-0242ac130003'); // RESULT uuidVersion('6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b'); // RESULT ``` + +> [!NOTE] +> This method returns `0` for the `NIL` UUID, and `15` for the `MAX` UUID. + ## Command Line UUIDs can be generated from the command line using `uuid`. @@ -421,7 +454,9 @@ import 'react-native-get-random-values'; import { v4 as uuidv4 } from 'uuid'; ``` -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`. + +> [!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`. ### Web Workers / Service Workers (Edge <= 18) diff --git a/examples/browser-esmodules/example.js b/examples/browser-esmodules/example.js index 5cbb6e78..c75df02e 100644 --- a/examples/browser-esmodules/example.js +++ b/examples/browser-esmodules/example.js @@ -1,5 +1,6 @@ import { NIL as NIL_UUID, + MAX as MAX_UUID, parse as uuidParse, stringify as uuidStringify, v1 as uuidv1, @@ -46,6 +47,7 @@ console.log('uuidv5() MY_NAMESPACE', uuidv5('Hello, World!', MY_NAMESPACE)); // Utility functions console.log('NIL_UUID', NIL_UUID); +console.log('MAX_UUID', MAX_UUID); console.log('uuidParse()', uuidParse(MY_NAMESPACE)); console.log('uuidStringify()', uuidStringify(uuidParse(MY_NAMESPACE))); console.log('uuidValidate()', uuidValidate(MY_NAMESPACE)); @@ -64,6 +66,7 @@ console.log('uuid.v5() URL', uuid.v5('http://example.com/hello', uuid.v5.URL)); console.log('uuid.v5() MY_NAMESPACE', uuid.v5('Hello, World!', MY_NAMESPACE)); console.log('uuid.NIL', uuid.NIL); +console.log('uuid.MAX', uuid.MAX); console.log('uuid.parse()', uuid.parse(MY_NAMESPACE)); console.log('uuid.stringify()', uuid.stringify(uuid.parse(MY_NAMESPACE))); console.log('uuid.validate()', uuid.validate(MY_NAMESPACE)); diff --git a/examples/browser-rollup/example-all.js b/examples/browser-rollup/example-all.js index 07af1908..35f81f8a 100644 --- a/examples/browser-rollup/example-all.js +++ b/examples/browser-rollup/example-all.js @@ -1,5 +1,6 @@ import { NIL as NIL_UUID, + MAX as MAX_UUID, parse as uuidParse, stringify as uuidStringify, v1 as uuidv1, @@ -51,6 +52,7 @@ testpage(function (addTest, done) { // Utility functions addTest('NIL_UUID', NIL_UUID); + addTest('MAX_UUID', MAX_UUID); addTest('uuidParse()', uuidParse(MY_NAMESPACE)); addTest('uuidStringify()', uuidStringify(uuidParse(MY_NAMESPACE))); addTest('uuidValidate()', uuidValidate(MY_NAMESPACE)); @@ -69,6 +71,7 @@ testpage(function (addTest, done) { addTest('uuid.v5() MY_NAMESPACE', uuid.v5('Hello, World!', MY_NAMESPACE)); addTest('uuid.NIL', uuid.NIL); + addTest('uuid.MAX', uuid.MAX); addTest('uuid.parse()', uuid.parse(MY_NAMESPACE)); addTest('uuid.stringify()', uuid.stringify(uuid.parse(MY_NAMESPACE))); addTest('uuid.validate()', uuid.validate(MY_NAMESPACE)); diff --git a/examples/browser-webpack/example-all-require.js b/examples/browser-webpack/example-all-require.js index 13fcc296..0ebb4bae 100644 --- a/examples/browser-webpack/example-all-require.js +++ b/examples/browser-webpack/example-all-require.js @@ -1,6 +1,7 @@ const uuid = require('uuid'); const { NIL: NIL_UUID, + MAX: MAX_UUID, parse: uuidParse, stringify: uuidStringify, v1: uuidv1, @@ -51,6 +52,7 @@ testpage(function (addTest, done) { // Utility functions addTest('NIL_UUID', NIL_UUID); + addTest('MAX_UUID', MAX_UUID); addTest('uuidParse()', uuidParse(MY_NAMESPACE)); addTest('uuidStringify()', uuidStringify(uuidParse(MY_NAMESPACE))); addTest('uuidValidate()', uuidValidate(MY_NAMESPACE)); @@ -69,6 +71,7 @@ testpage(function (addTest, done) { addTest('uuid.v5() MY_NAMESPACE', uuid.v5('Hello, World!', MY_NAMESPACE)); addTest('uuid.NIL', uuid.NIL); + addTest('uuid.MAX', uuid.MAX); addTest('uuid.parse()', uuid.parse(MY_NAMESPACE)); addTest('uuid.stringify()', uuid.stringify(uuid.parse(MY_NAMESPACE))); addTest('uuid.validate()', uuid.validate(MY_NAMESPACE)); diff --git a/examples/browser-webpack/example-all.js b/examples/browser-webpack/example-all.js index 07af1908..35f81f8a 100644 --- a/examples/browser-webpack/example-all.js +++ b/examples/browser-webpack/example-all.js @@ -1,5 +1,6 @@ import { NIL as NIL_UUID, + MAX as MAX_UUID, parse as uuidParse, stringify as uuidStringify, v1 as uuidv1, @@ -51,6 +52,7 @@ testpage(function (addTest, done) { // Utility functions addTest('NIL_UUID', NIL_UUID); + addTest('MAX_UUID', MAX_UUID); addTest('uuidParse()', uuidParse(MY_NAMESPACE)); addTest('uuidStringify()', uuidStringify(uuidParse(MY_NAMESPACE))); addTest('uuidValidate()', uuidValidate(MY_NAMESPACE)); @@ -69,6 +71,7 @@ testpage(function (addTest, done) { addTest('uuid.v5() MY_NAMESPACE', uuid.v5('Hello, World!', MY_NAMESPACE)); addTest('uuid.NIL', uuid.NIL); + addTest('uuid.MAX', uuid.MAX); addTest('uuid.parse()', uuid.parse(MY_NAMESPACE)); addTest('uuid.stringify()', uuid.stringify(uuid.parse(MY_NAMESPACE))); addTest('uuid.validate()', uuid.validate(MY_NAMESPACE)); diff --git a/examples/node-commonjs/example.js b/examples/node-commonjs/example.js index 8d773de5..72f58a09 100644 --- a/examples/node-commonjs/example.js +++ b/examples/node-commonjs/example.js @@ -1,5 +1,6 @@ const { NIL: NIL_UUID, + MAX: MAX_UUID, parse: uuidParse, stringify: uuidStringify, v1: uuidv1, @@ -47,6 +48,7 @@ console.log('uuidv5() MY_NAMESPACE', uuidv5('Hello, World!', MY_NAMESPACE)); // Utility functions console.log('NIL_UUID', NIL_UUID); +console.log('MAX_UUID', MAX_UUID); console.log('uuidParse()', uuidParse(MY_NAMESPACE)); console.log('uuidStringify()', uuidStringify(uuidParse(MY_NAMESPACE))); console.log('uuidValidate()', uuidValidate(MY_NAMESPACE)); @@ -65,6 +67,7 @@ console.log('uuid.v5() URL', uuid.v5('http://example.com/hello', uuid.v5.URL)); console.log('uuid.v5() MY_NAMESPACE', uuid.v5('Hello, World!', MY_NAMESPACE)); console.log('uuid.NIL', uuid.NIL); +console.log('uuid.MAX', uuid.MAX); console.log('uuid.parse()', uuid.parse(MY_NAMESPACE)); console.log('uuid.stringify()', uuid.stringify(uuid.parse(MY_NAMESPACE))); console.log('uuid.validate()', uuid.validate(MY_NAMESPACE)); diff --git a/examples/node-esmodules/example.mjs b/examples/node-esmodules/example.mjs index 433170d1..3eb9b474 100644 --- a/examples/node-esmodules/example.mjs +++ b/examples/node-esmodules/example.mjs @@ -1,5 +1,6 @@ import { NIL as NIL_UUID, + MAX as MAX_UUID, parse as uuidParse, stringify as uuidStringify, v1 as uuidv1, @@ -46,6 +47,7 @@ console.log('uuidv5() MY_NAMESPACE', uuidv5('Hello, World!', MY_NAMESPACE)); // Utility functions console.log('NIL_UUID', NIL_UUID); +console.log('MAX_UUID', MAX_UUID); console.log('uuidParse()', uuidParse(MY_NAMESPACE)); console.log('uuidStringify()', uuidStringify(uuidParse(MY_NAMESPACE))); console.log('uuidValidate()', uuidValidate(MY_NAMESPACE)); @@ -64,6 +66,7 @@ console.log('uuid.v5() URL', uuid.v5('http://example.com/hello', uuid.v5.URL)); console.log('uuid.v5() MY_NAMESPACE', uuid.v5('Hello, World!', MY_NAMESPACE)); console.log('uuid.NIL', uuid.NIL); +console.log('uuid.MAX', uuid.MAX); console.log('uuid.parse()', uuid.parse(MY_NAMESPACE)); console.log('uuid.stringify()', uuid.stringify(uuid.parse(MY_NAMESPACE))); console.log('uuid.validate()', uuid.validate(MY_NAMESPACE)); diff --git a/src/index.js b/src/index.js index c982986c..f6edc0ea 100644 --- a/src/index.js +++ b/src/index.js @@ -4,6 +4,7 @@ export { default as v4 } from './v4.js'; export { default as v5 } from './v5.js'; export { default as v7 } from './v7.js'; export { default as NIL } from './nil.js'; +export { default as MAX } from './max.js'; export { default as version } from './version.js'; export { default as validate } from './validate.js'; export { default as stringify } from './stringify.js'; diff --git a/src/max.js b/src/max.js new file mode 100644 index 00000000..58951f65 --- /dev/null +++ b/src/max.js @@ -0,0 +1 @@ +export default 'ffffffff-ffff-ffff-ffff-ffffffffffff'; diff --git a/src/regex.js b/src/regex.js index 0e7a4590..3e385919 100644 --- a/src/regex.js +++ b/src/regex.js @@ -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; +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; diff --git a/test/browser/browser.spec.js b/test/browser/browser.spec.js index df7deb4b..6f02731e 100644 --- a/test/browser/browser.spec.js +++ b/test/browser/browser.spec.js @@ -15,6 +15,7 @@ const v5url = (result) => expect(result).toBe('3bbcee75-cecc-5b56-8031-b6641c1ed const v5custom = (result) => expect(result).toBe('c49c5142-4d9a-5940-a926-612ede0ec632'); const nil = (result) => expect(result).toBe('00000000-0000-0000-0000-000000000000'); +const max = (result) => expect(result).toBe('ffffffff-ffff-ffff-ffff-ffffffffffff'); const parse = (result) => expect(result).toEqual('85,35,141,21,201,38,69,152,180,157,207,78,145,59,161,60'); const stringify = (result) => expect(result).toBe('55238d15-c926-4598-b49d-cf4e913ba13c'); @@ -33,6 +34,7 @@ const expectations = { 'uuidv5() MY_NAMESPACE': v5custom, NIL_UUID: nil, + MAX_UUID: max, 'uuidParse()': parse, 'uuidStringify()': stringify, 'uuidValidate()': validate, @@ -49,6 +51,7 @@ const expectations = { 'uuid.v5() MY_NAMESPACE': v5custom, 'uuid.NIL': nil, + 'uuid.MAX': max, 'uuid.parse()': parse, 'uuid.stringify()': stringify, 'uuid.validate()': validate, diff --git a/test/unit/validate.test.js b/test/unit/validate.test.js index 3357d28e..87f04473 100644 --- a/test/unit/validate.test.js +++ b/test/unit/validate.test.js @@ -1,10 +1,12 @@ import assert from 'assert'; import validate from '../../src/validate.js'; import NIL from '../../src/nil.js'; +import MAX from '../../src/max.js'; describe('validate', () => { test('validate uuid', () => { assert.strictEqual(validate(NIL), true); + assert.strictEqual(validate(MAX), true); // test valid UUID versions diff --git a/test/unit/version.test.js b/test/unit/version.test.js index f8edba8e..2c0e63c7 100644 --- a/test/unit/version.test.js +++ b/test/unit/version.test.js @@ -1,10 +1,12 @@ import assert from 'assert'; import version from '../../src/version.js'; import NIL from '../../src/nil.js'; +import MAX from '../../src/max.js'; describe('version', () => { test('check uuid version', () => { assert.strictEqual(version(NIL), 0); + assert.strictEqual(version(MAX), 15); assert.strictEqual(version('d9428888-122b-11e1-b85c-61cd3cbb3210'), 1); diff --git a/wrapper.mjs b/wrapper.mjs index 8e4a3e74..9ca7e485 100644 --- a/wrapper.mjs +++ b/wrapper.mjs @@ -5,6 +5,7 @@ export const v4 = uuid.v4; export const v5 = uuid.v5; export const v7 = uuid.v7; export const NIL = uuid.NIL; +export const MAX = uuid.MAX; export const version = uuid.version; export const validate = uuid.validate; export const stringify = uuid.stringify;