diff --git a/.gitignore b/.gitignore index 67b36b30..a74c6cda 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ dist/ browserstack.err local.log *.tgz +.envrc diff --git a/examples/browser-rollup/example-all.js b/examples/browser-rollup/example-all.js index f67de6c2..4e421731 100644 --- a/examples/browser-rollup/example-all.js +++ b/examples/browser-rollup/example-all.js @@ -1,9 +1,20 @@ -import { v1 as uuidv1, v4 as uuidv4, v3 as uuidv3, v5 as uuidv5 } from 'uuid'; +import { + parse as uuidParse, + stringify as uuidStringify, + v1 as uuidv1, + v3 as uuidv3, + v4 as uuidv4, + v5 as uuidv5, + validate as uuidValidate, + version as uuidVersion, +} from 'uuid'; import * as uuid from 'uuid'; import testpage from '../utils/testpage'; testpage(function (addTest, done) { + addTest('Named exports'); + addTest('uuidv1()', uuidv1()); addTest('uuidv4()', uuidv4()); @@ -34,7 +45,13 @@ testpage(function (addTest, done) { // const MY_NAMESPACE = '1b671a64-40d5-491e-99b0-da01ff1f3341'; addTest('uuidv5() MY_NAMESPACE', uuidv5('Hello, World!', MY_NAMESPACE)); - addTest('Same with default export'); + // Utility functions + addTest('uuidParse()', uuidParse(MY_NAMESPACE)); + addTest('uuidStringify()', uuidStringify(uuidParse(MY_NAMESPACE))); + addTest('uuidValidate()', uuidValidate(MY_NAMESPACE)); + addTest('uuidVersion()', uuidVersion(MY_NAMESPACE)); + + addTest('Default export'); addTest('uuid.v1()', uuid.v1()); addTest('uuid.v4()', uuid.v4()); @@ -45,5 +62,10 @@ testpage(function (addTest, done) { addTest('uuid.v5() URL', uuid.v5('http://example.com/hello', uuid.v5.URL)); addTest('uuid.v5() MY_NAMESPACE', uuid.v5('Hello, World!', MY_NAMESPACE)); + addTest('uuid.parse()', uuid.parse(MY_NAMESPACE)); + addTest('uuid.stringify()', uuid.stringify(uuid.parse(MY_NAMESPACE))); + addTest('uuid.validate()', uuid.validate(MY_NAMESPACE)); + addTest('uuid.version()', uuid.version(MY_NAMESPACE)); + done(); }); diff --git a/examples/browser-webpack/example-all.js b/examples/browser-webpack/example-all.js index f67de6c2..4e421731 100644 --- a/examples/browser-webpack/example-all.js +++ b/examples/browser-webpack/example-all.js @@ -1,9 +1,20 @@ -import { v1 as uuidv1, v4 as uuidv4, v3 as uuidv3, v5 as uuidv5 } from 'uuid'; +import { + parse as uuidParse, + stringify as uuidStringify, + v1 as uuidv1, + v3 as uuidv3, + v4 as uuidv4, + v5 as uuidv5, + validate as uuidValidate, + version as uuidVersion, +} from 'uuid'; import * as uuid from 'uuid'; import testpage from '../utils/testpage'; testpage(function (addTest, done) { + addTest('Named exports'); + addTest('uuidv1()', uuidv1()); addTest('uuidv4()', uuidv4()); @@ -34,7 +45,13 @@ testpage(function (addTest, done) { // const MY_NAMESPACE = '1b671a64-40d5-491e-99b0-da01ff1f3341'; addTest('uuidv5() MY_NAMESPACE', uuidv5('Hello, World!', MY_NAMESPACE)); - addTest('Same with default export'); + // Utility functions + addTest('uuidParse()', uuidParse(MY_NAMESPACE)); + addTest('uuidStringify()', uuidStringify(uuidParse(MY_NAMESPACE))); + addTest('uuidValidate()', uuidValidate(MY_NAMESPACE)); + addTest('uuidVersion()', uuidVersion(MY_NAMESPACE)); + + addTest('Default export'); addTest('uuid.v1()', uuid.v1()); addTest('uuid.v4()', uuid.v4()); @@ -45,5 +62,10 @@ testpage(function (addTest, done) { addTest('uuid.v5() URL', uuid.v5('http://example.com/hello', uuid.v5.URL)); addTest('uuid.v5() MY_NAMESPACE', uuid.v5('Hello, World!', MY_NAMESPACE)); + addTest('uuid.parse()', uuid.parse(MY_NAMESPACE)); + addTest('uuid.stringify()', uuid.stringify(uuid.parse(MY_NAMESPACE))); + addTest('uuid.validate()', uuid.validate(MY_NAMESPACE)); + addTest('uuid.version()', uuid.version(MY_NAMESPACE)); + done(); }); diff --git a/examples/utils/testpage.js b/examples/utils/testpage.js index 13cdb6b5..401d88a5 100644 --- a/examples/utils/testpage.js +++ b/examples/utils/testpage.js @@ -1,23 +1,38 @@ -export default function test(callback) { - const ul = document.createElement('ul'); - document.body.appendChild(ul); +document.write( + '', +); +export default function test(callback) { function addTest(title, result) { - const li = document.createElement('li'); - - const h2 = document.createElement('h2'); - h2.innerHTML = title; - li.appendChild(h2); + // join() result if it's array-like + if (result instanceof Uint8Array || Array.isArray(result)) { + result = Array.prototype.join.apply(result); + } - const p = document.createElement('p'); - p.innerHTML = result; - li.appendChild(p); + let el; + if (result === undefined) { + el = document.createElement('h2'); + el.innerHTML = title; + } else { + el = document.createElement('div'); + el.className = 'test_result'; + el.innerHTML = '