Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## Unreleased

### Features

- Add `MAX` constant ([#714](https://github.com/uuidjs/uuid/issues/714))

## [9.0.0](https://github.com/uuidjs/uuid/compare/v8.3.2...v9.0.0) (2022-09-05)

### ⚠ BREAKING CHANGES
Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ For timestamp UUIDs, namespace UUIDs, and other options read on ...
| | | |
| --- | --- | --- |
| [`uuid.NIL`](#uuidnil) | The nil UUID string (all zeros) | New in `[email protected]` |
| [`uuid.MAX`](#uuidmax) | The max UUID string (all ones) | New in `[email protected]` |
| [`uuid.parse()`](#uuidparsestr) | Convert UUID string to array of bytes | New in `[email protected]` |
| [`uuid.stringify()`](#uuidstringifyarr-offset) | Convert array of bytes to UUID string | New in `[email protected]` |
| [`uuid.v1()`](#uuidv1options-buffer-offset) | Create a version 1 (timestamp) UUID | |
Expand All @@ -76,6 +77,18 @@ import { NIL as NIL_UUID } from 'uuid';
NIL_UUID; // ⇨ '00000000-0000-0000-0000-000000000000'
```

### uuid.MAX

The max UUID string (all zeros).

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
Expand Down
13 changes: 13 additions & 0 deletions README_js.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ For timestamp UUIDs, namespace UUIDs, and other options read on ...
| | | |
| --- | --- | --- |
| [`uuid.NIL`](#uuidnil) | The nil UUID string (all zeros) | New in `[email protected]` |
| [`uuid.MAX`](#uuidmax) | The max UUID string (all ones) | New in `[email protected]` |
| [`uuid.parse()`](#uuidparsestr) | Convert UUID string to array of bytes | New in `[email protected]` |
| [`uuid.stringify()`](#uuidstringifyarr-offset) | Convert array of bytes to UUID string | New in `[email protected]` |
| [`uuid.v1()`](#uuidv1options-buffer-offset) | Create a version 1 (timestamp) UUID | |
Expand All @@ -90,6 +91,18 @@ import { NIL as NIL_UUID } from 'uuid';
NIL_UUID; // RESULT
```

### uuid.MAX

The max UUID string (all zeros).

Example:

```javascript --run
import { MAX as MAX_UUID } from 'uuid';

MAX_UUID; // RESULT
```

### uuid.parse(str)

Convert UUID string to array of bytes
Expand Down
3 changes: 3 additions & 0 deletions examples/browser-esmodules/example.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
NIL as NIL_UUID,
MAX as MAX_UUID,
parse as uuidParse,
stringify as uuidStringify,
v1 as uuidv1,
Expand Down Expand Up @@ -43,6 +44,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));
Expand All @@ -60,6 +62,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));
Expand Down
3 changes: 3 additions & 0 deletions examples/browser-rollup/example-all.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
NIL as NIL_UUID,
MAX as MAX_UUID,
parse as uuidParse,
stringify as uuidStringify,
v1 as uuidv1,
Expand Down Expand Up @@ -48,6 +49,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));
Expand All @@ -65,6 +67,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));
Expand Down
3 changes: 3 additions & 0 deletions examples/browser-webpack/example-all-require.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const uuid = require('uuid');
const {
NIL: NIL_UUID,
MAX: MAX_UUID,
parse: uuidParse,
stringify: uuidStringify,
v1: uuidv1,
Expand Down Expand Up @@ -48,6 +49,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));
Expand All @@ -65,6 +67,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));
Expand Down
3 changes: 3 additions & 0 deletions examples/browser-webpack/example-all.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
NIL as NIL_UUID,
MAX as MAX_UUID,
parse as uuidParse,
stringify as uuidStringify,
v1 as uuidv1,
Expand Down Expand Up @@ -48,6 +49,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));
Expand All @@ -65,6 +67,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));
Expand Down
3 changes: 3 additions & 0 deletions examples/node-commonjs/example.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const {
NIL: NIL_UUID,
MAX: MAX_UUID,
parse: uuidParse,
stringify: uuidStringify,
v1: uuidv1,
Expand Down Expand Up @@ -44,6 +45,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));
Expand All @@ -61,6 +63,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));
Expand Down
3 changes: 3 additions & 0 deletions examples/node-esmodules/example.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
NIL as NIL_UUID,
MAX as MAX_UUID,
parse as uuidParse,
stringify as uuidStringify,
v1 as uuidv1,
Expand Down Expand Up @@ -43,6 +44,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));
Expand All @@ -60,6 +62,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));
Expand Down
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export { default as v3 } from './v3.js';
export { default as v4 } from './v4.js';
export { default as v5 } from './v5.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';
Expand Down
1 change: 1 addition & 0 deletions src/max.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 'ffffffff-ffff-ffff-ffff-ffffffffffff';
3 changes: 3 additions & 0 deletions test/browser/browser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,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');
Expand All @@ -30,6 +31,7 @@ const expectations = {
'uuidv5() MY_NAMESPACE': v5custom,

NIL_UUID: nil,
MAX_UUID: max,
'uuidParse()': parse,
'uuidStringify()': stringify,
'uuidValidate()': validate,
Expand All @@ -45,6 +47,7 @@ const expectations = {
'uuid.v5() MY_NAMESPACE': v5custom,

'uuid.NIL': nil,
'uuid.MAX': max,
'uuid.parse()': parse,
'uuid.stringify()': stringify,
'uuid.validate()': validate,
Expand Down
2 changes: 2 additions & 0 deletions test/unit/validate.test.js
Original file line number Diff line number Diff line change
@@ -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), false);

assert.strictEqual(validate('d9428888-122b-11e1-b85c-61cd3cbb3210'), true);

Expand Down
3 changes: 3 additions & 0 deletions test/unit/version.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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', () => {
Expand All @@ -18,6 +19,8 @@ describe('version', () => {

assert.throws(() => version(''));

assert.throws(() => version(MAX));

assert.throws(() => version('invalid uuid string'));

assert.throws(() => {
Expand Down
1 change: 1 addition & 0 deletions wrapper.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const v3 = uuid.v3;
export const v4 = uuid.v4;
export const v5 = uuid.v5;
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;
Expand Down