uuid 8.0.0-beta.0 → 8.2.0

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/CHANGELOG.md CHANGED
@@ -2,6 +2,71 @@
2
2
 
3
3
  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.
4
4
 
5
+ ## [8.2.0](https://github.com/uuidjs/uuid/compare/v8.1.0...v8.2.0) (2020-06-23)
6
+
7
+ ### Features
8
+
9
+ - improve performance of v1 string representation ([#453](https://github.com/uuidjs/uuid/issues/453)) ([0ee0b67](https://github.com/uuidjs/uuid/commit/0ee0b67c37846529c66089880414d29f3ae132d5))
10
+ - remove deprecated v4 string parameter ([#454](https://github.com/uuidjs/uuid/issues/454)) ([88ce3ca](https://github.com/uuidjs/uuid/commit/88ce3ca0ba046f60856de62c7ce03f7ba98ba46c)), closes [#437](https://github.com/uuidjs/uuid/issues/437)
11
+ - support jspm ([#473](https://github.com/uuidjs/uuid/issues/473)) ([e9f2587](https://github.com/uuidjs/uuid/commit/e9f2587a92575cac31bc1d4ae944e17c09756659))
12
+
13
+ ### Bug Fixes
14
+
15
+ - prepare package exports for webpack 5 ([#468](https://github.com/uuidjs/uuid/issues/468)) ([8d6e6a5](https://github.com/uuidjs/uuid/commit/8d6e6a5f8965ca9575eb4d92e99a43435f4a58a8))
16
+
17
+ ## [8.1.0](https://github.com/uuidjs/uuid/compare/v8.0.0...v8.1.0) (2020-05-20)
18
+
19
+ ### Features
20
+
21
+ - improve v4 performance by reusing random number array ([#435](https://github.com/uuidjs/uuid/issues/435)) ([bf4af0d](https://github.com/uuidjs/uuid/commit/bf4af0d711b4d2ed03d1f74fd12ad0baa87dc79d))
22
+ - optimize V8 performance of bytesToUuid ([#434](https://github.com/uuidjs/uuid/issues/434)) ([e156415](https://github.com/uuidjs/uuid/commit/e156415448ec1af2351fa0b6660cfb22581971f2))
23
+
24
+ ### Bug Fixes
25
+
26
+ - export package.json required by react-native and bundlers ([#449](https://github.com/uuidjs/uuid/issues/449)) ([be1c8fe](https://github.com/uuidjs/uuid/commit/be1c8fe9a3206c358e0059b52fafd7213aa48a52)), closes [/github.com/ai/nanoevents/issues/44#issuecomment-602010343](https://github.com/uuidjs//github.com/ai/nanoevents/issues/44/issues/issuecomment-602010343) [#444](https://github.com/uuidjs/uuid/issues/444)
27
+
28
+ ## [8.0.0](https://github.com/uuidjs/uuid/compare/v7.0.3...v8.0.0) (2020-04-29)
29
+
30
+ ### ⚠ BREAKING CHANGES
31
+
32
+ - For native ECMAScript Module (ESM) usage in Node.js only named exports are exposed, there is no more default export.
33
+
34
+ ```diff
35
+ -import uuid from 'uuid';
36
+ -console.log(uuid.v4()); // -> 'cd6c3b08-0adc-4f4b-a6ef-36087a1c9869'
37
+ +import { v4 as uuidv4 } from 'uuid';
38
+ +uuidv4(); // ⇨ '9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d'
39
+ ```
40
+
41
+ - Deep requiring specific algorithms of this library like `require('uuid/v4')`, which has been deprecated in `uuid@7`, is no longer supported.
42
+
43
+ Instead use the named exports that this module exports.
44
+
45
+ For ECMAScript Modules (ESM):
46
+
47
+ ```diff
48
+ -import uuidv4 from 'uuid/v4';
49
+ +import { v4 as uuidv4 } from 'uuid';
50
+ uuidv4();
51
+ ```
52
+
53
+ For CommonJS:
54
+
55
+ ```diff
56
+ -const uuidv4 = require('uuid/v4');
57
+ +const { v4: uuidv4 } = require('uuid');
58
+ uuidv4();
59
+ ```
60
+
61
+ ### Features
62
+
63
+ - native Node.js ES Modules (wrapper approach) ([#423](https://github.com/uuidjs/uuid/issues/423)) ([2d9f590](https://github.com/uuidjs/uuid/commit/2d9f590ad9701d692625c07ed62f0a0f91227991)), closes [#245](https://github.com/uuidjs/uuid/issues/245) [#419](https://github.com/uuidjs/uuid/issues/419) [#342](https://github.com/uuidjs/uuid/issues/342)
64
+ - remove deep requires ([#426](https://github.com/uuidjs/uuid/issues/426)) ([daf72b8](https://github.com/uuidjs/uuid/commit/daf72b84ceb20272a81bb5fbddb05dd95922cbba))
65
+
66
+ ### Bug Fixes
67
+
68
+ - add CommonJS syntax example to README quickstart section ([#417](https://github.com/uuidjs/uuid/issues/417)) ([e0ec840](https://github.com/uuidjs/uuid/commit/e0ec8402c7ad44b7ef0453036c612f5db513fda0))
69
+
5
70
  ### [7.0.3](https://github.com/uuidjs/uuid/compare/v7.0.2...v7.0.3) (2020-03-31)
6
71
 
7
72
  ### Bug Fixes
@@ -27,21 +92,11 @@ All notable changes to this project will be documented in this file. See [standa
27
92
 
28
93
  ### ⚠ BREAKING CHANGES
29
94
 
30
- - The default export, which used to be the v4() method
31
- but which was already discouraged in v3.x of this library, has been
32
- removed.
33
- - Explicitly note that deep imports of the different uuid
34
- version functions are deprecated and no longer encouraged and that
35
- ECMAScript module named imports should be used instead.
36
- Emit a deprecation warning for people who deep-require the different
37
- algorithm variants.
38
- - Remove builtin support for insecure random number
39
- generators in the browser. Users who want that will have to supply their
40
- own random number generator function.
41
- - Remove support for generating v3 and v5 UUIDs in
42
- Node.js<4.x
43
- - Convert code base to ECMAScript Modules (ESM) and
44
- release CommonJS build for node and ESM build for browser bundlers.
95
+ - The default export, which used to be the v4() method but which was already discouraged in v3.x of this library, has been removed.
96
+ - Explicitly note that deep imports of the different uuid version functions are deprecated and no longer encouraged and that ECMAScript module named imports should be used instead. Emit a deprecation warning for people who deep-require the different algorithm variants.
97
+ - Remove builtin support for insecure random number generators in the browser. Users who want that will have to supply their own random number generator function.
98
+ - Remove support for generating v3 and v5 UUIDs in Node.js<4.x
99
+ - Convert code base to ECMAScript Modules (ESM) and release CommonJS build for node and ESM build for browser bundlers.
45
100
 
46
101
  ### Features
47
102
 
package/CONTRIBUTING.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # Contributing
2
2
 
3
- Please feel free to file GitHub Issues or propose Pull Requests. We're always happy to discuss
4
- improvements to this library!
3
+ Please feel free to file GitHub Issues or propose Pull Requests. We're always happy to discuss improvements to this library!
5
4
 
6
5
  ## Testing
7
6
 
@@ -11,8 +10,7 @@ npm test
11
10
 
12
11
  ## Releasing
13
12
 
14
- Releases are supposed to be done from master, version bumping is automated through
15
- [`standard-version`](https://github.com/conventional-changelog/standard-version):
13
+ Releases are supposed to be done from master, version bumping is automated through [`standard-version`](https://github.com/conventional-changelog/standard-version):
16
14
 
17
15
  ```shell
18
16
  npm run release -- --dry-run # verify output manually
package/LICENSE.md CHANGED
@@ -2,20 +2,8 @@ The MIT License (MIT)
2
2
 
3
3
  Copyright (c) 2010-2020 Robert Kieffer and other contributors
4
4
 
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
11
6
 
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14
8
 
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -8,7 +8,7 @@ For the creation of [RFC4122](http://www.ietf.org/rfc/rfc4122.txt) UUIDs
8
8
 
9
9
  - **Complete** - Support for RFC4122 version 1, 3, 4, and 5 UUIDs
10
10
  - **Cross-platform** - Support for ...
11
- - CommonJS, [ECMAScript Modules](#ecmascript-modules) and UMD builds
11
+ - CommonJS, [ECMAScript Modules](#ecmascript-modules) and [CDN builds](#cdn-builds)
12
12
  - Node 8, 10, 12, 14
13
13
  - Chrome, Safari, Firefox, Edge, IE 11 browsers
14
14
  - Webpack and rollup.js module bundlers
@@ -17,8 +17,7 @@ For the creation of [RFC4122](http://www.ietf.org/rfc/rfc4122.txt) UUIDs
17
17
  - **Small** - Zero-dependency, small footprint, plays nice with "tree shaking" packagers
18
18
  - **CLI** - Includes the [`uuid` command line](#command-line) utility
19
19
 
20
- **Upgrading from uuid\@3?** Your code is probably okay, but check out [Upgrading
21
- From uuid\@3](#upgrading-from-uuid3) for details.
20
+ **Upgrading from uuid\@3?** Your code is probably okay, but check out [Upgrading From uuid\@3](#upgrading-from-uuid3) for details.
22
21
 
23
22
  ## Quickstart
24
23
 
@@ -26,8 +25,7 @@ From uuid\@3](#upgrading-from-uuid3) for details.
26
25
  npm install uuid
27
26
  ```
28
27
 
29
- Once installed, decide which type of UUID you need. RFC4122 provides for four
30
- versions, all of which are supported here. In order of popularity, they are:
28
+ Once installed, decide which type of UUID you need. RFC4122 provides for four versions, all of which are supported here. In order of popularity, they are:
31
29
 
32
30
  - Version 4 (random) - Created from cryptographically-strong random values
33
31
  - Version 1 (timestamp) - Created from the system clock (plus random values)
@@ -61,12 +59,9 @@ uuidv1(); // ⇨ '2c5ea4c0-4067-11e9-8bad-9b1deb4d3b7d'
61
59
 
62
60
  ### Create Version 3 or Version 5 (Namespace) UUIDs
63
61
 
64
- &#x26a0;&#xfe0f; Version 3 and Version 5 UUIDs are basically the same, differing
65
- only in the underlying hash algorithm. Note that per the RFC, "_If backward
66
- compatibility is not an issue, SHA-1 [Version 5] is preferred_."
62
+ &#x26a0;&#xfe0f; Version 3 and Version 5 UUIDs are basically the same, differing only in the underlying hash algorithm. Note that per the RFC, "_If backward compatibility is not an issue, SHA-1 [Version 5] is preferred_."
67
63
 
68
- &#x26a0;&#xfe0f; If using a custom namespace **be sure to generate your own
69
- namespace UUID**. You can grab one [here](https://www.uuidgenerator.net/).
64
+ &#x26a0;&#xfe0f; If using a custom namespace **be sure to generate your own namespace UUID**. You can grab one [here](https://www.uuidgenerator.net/).
70
65
 
71
66
  ```javascript
72
67
  import { v5 as uuidv5 } from 'uuid'; // For version 5
@@ -280,7 +275,7 @@ ddeb27fb-d9a0-4624-be4d-4615062daed4
280
275
 
281
276
  The default is to generate version 4 UUIDS, however the other versions are supported. Type `uuid --help` for details:
282
277
 
283
- ```
278
+ ```shell
284
279
  $ uuid --help
285
280
 
286
281
  Usage:
@@ -297,12 +292,7 @@ defined by RFC4122
297
292
 
298
293
  ## ECMAScript Modules
299
294
 
300
- This library comes with [ECMAScript
301
- Modules](https://www.ecma-international.org/ecma-262/6.0/#sec-modules) (ESM) support for Node.js
302
- versions that support it ([example](./examples/node-esmodules/)) as well as bundlers like
303
- [rollup.js](https://rollupjs.org/guide/en/#tree-shaking) ([example](./examples/browser-rollup/))
304
- and [webpack](https://webpack.js.org/guides/tree-shaking/)
305
- ([example](./examples/browser-webpack/)) (targeting both, Node.js and browser environments).
295
+ This library comes with [ECMAScript Modules](https://www.ecma-international.org/ecma-262/6.0/#sec-modules) (ESM) support for Node.js versions that support it ([example](./examples/node-esmodules/)) as well as bundlers like [rollup.js](https://rollupjs.org/guide/en/#tree-shaking) ([example](./examples/browser-rollup/)) and [webpack](https://webpack.js.org/guides/tree-shaking/) ([example](./examples/browser-webpack/)) (targeting both, Node.js and browser environments).
306
296
 
307
297
  ```javascript
308
298
  import { v4 as uuidv4 } from 'uuid';
@@ -311,41 +301,58 @@ uuidv4(); // ⇨ '1b9d6bcd-bbfd-4b2d-9b5d-ab8dfbbd4bed'
311
301
 
312
302
  To run the examples you must first create a dist build of this library in the module root:
313
303
 
314
- ```
304
+ ```shell
315
305
  npm run build
316
306
  ```
317
307
 
318
- ## UMD Builds
308
+ ## CDN Builds
309
+
310
+ ### ECMAScript Modules
319
311
 
320
- If you want to load a minified UMD build directly in the browser you can use one of the popular npm
321
- CDNs:
312
+ To load this module directly into modern browsers that [support loading ECMAScript Modules](https://caniuse.com/#feat=es6-module) you can make use of [jspm](https://jspm.org/):
322
313
 
323
314
  ```html
324
- <script src="https://unpkg.com/uuid@latest/dist/umd/uuidv4.min.js"></script>
325
- <script>
326
- alert(uuidv4());
315
+ <script type="module">
316
+ import { v4 as uuidv4 } from 'https://jspm.dev/uuid';
317
+ console.log(uuidv4()); // ⇨ '1b9d6bcd-bbfd-4b2d-9b5d-ab8dfbbd4bed'
327
318
  </script>
328
319
  ```
329
320
 
330
- or
321
+ ### UMD
322
+
323
+ To load this module directly into older browsers you can use the [UMD (Universal Module Definition)](https://github.com/umdjs/umd) builds from any of the following CDNs:
324
+
325
+ **Using [UNPKG](https://unpkg.com/uuid@latest/dist/umd/)**:
326
+
327
+ ```html
328
+ <script src="https://unpkg.com/uuid@latest/dist/umd/uuidv4.min.js"></script>
329
+ ```
330
+
331
+ **Using [jsDelivr](https://cdn.jsdelivr.net/npm/uuid@latest/dist/umd/)**:
331
332
 
332
333
  ```html
333
334
  <script src="https://cdn.jsdelivr.net/npm/uuid@latest/dist/umd/uuidv4.min.js"></script>
335
+ ```
336
+
337
+ **Using [cdnjs](https://cdnjs.com/libraries/uuid)**:
338
+
339
+ ```html
340
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/uuid/8.1.0/uuidv4.min.js"></script>
341
+ ```
342
+
343
+ These CDNs all provide the same [`uuidv4()`](#version-4-random) method:
344
+
345
+ ```html
334
346
  <script>
335
- alert(uuidv4());
347
+ uuidv4(); // ⇨ '55af1e37-0734-46d8-b070-a1e42e4fc392'
336
348
  </script>
337
349
  ```
338
350
 
339
- Available bundles:
340
-
341
- - https://unpkg.com/uuid@latest/dist/umd/
342
- - https://cdn.jsdelivr.net/npm/uuid@latest/dist/umd/
351
+ Methods for the other algorithms ([`uuidv1()`](#version-1-timestamp), [`uuidv3()`](#version-3-namespace) and [`uuidv5()`](#version-5-namespace)) are available from the files `uuidv1.min.js`, `uuidv3.min.js` and `uuidv5.min.js` respectively.
343
352
 
344
353
  ## "getRandomValues() not supported"
345
354
 
346
- This error occurs in environments where the standard
347
- [`crypto.getRandomValues()`](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues)
348
- API is not supported. This issue can be resolved by adding an appropriate polyfill:
355
+ This error occurs in environments where the standard [`crypto.getRandomValues()`](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues) API is not supported. This issue can be resolved by adding an appropriate polyfill:
349
356
 
350
357
  ### React Native
351
358
 
@@ -359,17 +366,13 @@ import { v4 as uuidv4 } from 'uuid';
359
366
 
360
367
  ### Web Workers / Service Workers (Edge <= 18)
361
368
 
362
- [In Edge <= 18, Web Crypto is not supported in Web Workers or Service
363
- Workers](https://caniuse.com/#feat=cryptography) and we are not aware of a polyfill (let us know if
364
- you find one, please).
369
+ [In Edge <= 18, Web Crypto is not supported in Web Workers or Service Workers](https://caniuse.com/#feat=cryptography) and we are not aware of a polyfill (let us know if you find one, please).
365
370
 
366
371
  ## Upgrading From uuid\@7
367
372
 
368
373
  ### Only Named Exports Supported When Using with Node.js ESM
369
374
 
370
- uuid\@7 did not come with native ECMAScript Module (ESM) support for Node.js. Importing it in
371
- Node.js ESM consequently imported the CommonJS source with a default export. This library now comes
372
- with true Node.js ESM support and only provides named exports.
375
+ uuid\@7 did not come with native ECMAScript Module (ESM) support for Node.js. Importing it in Node.js ESM consequently imported the CommonJS source with a default export. This library now comes with true Node.js ESM support and only provides named exports.
373
376
 
374
377
  Instead of doing:
375
378
 
@@ -387,31 +390,24 @@ uuidv4();
387
390
 
388
391
  ### Deep Requires No Longer Supported
389
392
 
390
- Deep requires like `require('uuid/v4')` [which have been deprecated in
391
- uuid\@7](#deep-requires-now-deprecated) are no longer supported.
393
+ Deep requires like `require('uuid/v4')` [which have been deprecated in uuid\@7](#deep-requires-now-deprecated) are no longer supported.
392
394
 
393
395
  ## Upgrading From uuid\@3
394
396
 
395
397
  "_Wait... what happened to uuid\@4 - uuid\@6?!?_"
396
398
 
397
- In order to avoid confusion with RFC [version 4](#version-4-random) and [version
398
- 5](#version-5-namespace) UUIDs, and a possible [version
399
- 6](http://gh.peabody.io/uuidv6/), releases 4 thru 6 of this module have been
400
- skipped. Hence, how we're now at uuid\@7.
399
+ In order to avoid confusion with RFC [version 4](#version-4-random) and [version 5](#version-5-namespace) UUIDs, and a possible [version 6](http://gh.peabody.io/uuidv6/), releases 4 thru 6 of this module have been skipped. Hence, how we're now at uuid\@7.
401
400
 
402
401
  ### Deep Requires Now Deprecated
403
402
 
404
- uuid\@3 encouraged the use of deep requires to minimize the bundle size of
405
- browser builds:
403
+ uuid\@3 encouraged the use of deep requires to minimize the bundle size of browser builds:
406
404
 
407
405
  ```javascript
408
406
  const uuidv4 = require('uuid/v4'); // <== NOW DEPRECATED!
409
407
  uuidv4();
410
408
  ```
411
409
 
412
- As of uuid\@7 this library now provides ECMAScript modules builds, which allow
413
- packagers like Webpack and Rollup to do "tree-shaking" to remove dead code.
414
- Instead, use the `import` syntax:
410
+ As of uuid\@7 this library now provides ECMAScript modules builds, which allow packagers like Webpack and Rollup to do "tree-shaking" to remove dead code. Instead, use the `import` syntax:
415
411
 
416
412
  ```javascript
417
413
  import { v4 as uuidv4 } from 'uuid';
@@ -9,17 +9,17 @@ exports.default = void 0;
9
9
  * Convert array of 16 byte values to UUID string format of the form:
10
10
  * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
11
11
  */
12
- var byteToHex = [];
12
+ const byteToHex = [];
13
13
 
14
- for (var i = 0; i < 256; ++i) {
15
- byteToHex[i] = (i + 0x100).toString(16).substr(1);
14
+ for (let i = 0; i < 256; ++i) {
15
+ byteToHex.push((i + 0x100).toString(16).substr(1));
16
16
  }
17
17
 
18
- function bytesToUuid(buf, offset) {
19
- var i = offset || 0;
20
- var bth = byteToHex; // join used to fix memory issue caused by concatenation: https://bugs.chromium.org/p/v8/issues/detail?id=3175#c4
18
+ function bytesToUuid(buf, offset_) {
19
+ const offset = offset_ || 0; // Note: Be careful editing this code! It's been tuned for performance
20
+ // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
21
21
 
22
- return [bth[buf[i++]], bth[buf[i++]], bth[buf[i++]], bth[buf[i++]], '-', bth[buf[i++]], bth[buf[i++]], '-', bth[buf[i++]], bth[buf[i++]], '-', bth[buf[i++]], bth[buf[i++]], '-', bth[buf[i++]], bth[buf[i++]], bth[buf[i++]], bth[buf[i++]], bth[buf[i++]], bth[buf[i++]]].join('');
22
+ return (byteToHex[buf[offset + 0]] + byteToHex[buf[offset + 1]] + byteToHex[buf[offset + 2]] + byteToHex[buf[offset + 3]] + '-' + byteToHex[buf[offset + 4]] + byteToHex[buf[offset + 5]] + '-' + byteToHex[buf[offset + 6]] + byteToHex[buf[offset + 7]] + '-' + byteToHex[buf[offset + 8]] + byteToHex[buf[offset + 9]] + '-' + byteToHex[buf[offset + 10]] + byteToHex[buf[offset + 11]] + byteToHex[buf[offset + 12]] + byteToHex[buf[offset + 13]] + byteToHex[buf[offset + 14]] + byteToHex[buf[offset + 15]]).toLowerCase();
23
23
  }
24
24
 
25
25
  var _default = bytesToUuid;
@@ -5,14 +5,14 @@
5
5
  var byteToHex = [];
6
6
 
7
7
  for (var i = 0; i < 256; ++i) {
8
- byteToHex[i] = (i + 0x100).toString(16).substr(1);
8
+ byteToHex.push((i + 0x100).toString(16).substr(1));
9
9
  }
10
10
 
11
- function bytesToUuid(buf, offset) {
12
- var i = offset || 0;
13
- var bth = byteToHex; // join used to fix memory issue caused by concatenation: https://bugs.chromium.org/p/v8/issues/detail?id=3175#c4
11
+ function bytesToUuid(buf, offset_) {
12
+ var offset = offset_ || 0; // Note: Be careful editing this code! It's been tuned for performance
13
+ // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
14
14
 
15
- return [bth[buf[i++]], bth[buf[i++]], bth[buf[i++]], bth[buf[i++]], '-', bth[buf[i++]], bth[buf[i++]], '-', bth[buf[i++]], bth[buf[i++]], '-', bth[buf[i++]], bth[buf[i++]], '-', bth[buf[i++]], bth[buf[i++]], bth[buf[i++]], bth[buf[i++]], bth[buf[i++]], bth[buf[i++]]].join('');
15
+ return (byteToHex[buf[offset + 0]] + byteToHex[buf[offset + 1]] + byteToHex[buf[offset + 2]] + byteToHex[buf[offset + 3]] + '-' + byteToHex[buf[offset + 4]] + byteToHex[buf[offset + 5]] + '-' + byteToHex[buf[offset + 6]] + byteToHex[buf[offset + 7]] + '-' + byteToHex[buf[offset + 8]] + byteToHex[buf[offset + 9]] + '-' + byteToHex[buf[offset + 10]] + byteToHex[buf[offset + 11]] + byteToHex[buf[offset + 12]] + byteToHex[buf[offset + 13]] + byteToHex[buf[offset + 14]] + byteToHex[buf[offset + 15]]).toLowerCase();
16
16
  }
17
17
 
18
18
  export default bytesToUuid;
@@ -19,12 +19,12 @@
19
19
  * See http://pajhome.org.uk/crypt/md5 for more info.
20
20
  */
21
21
  function md5(bytes) {
22
- if (typeof bytes == 'string') {
22
+ if (typeof bytes === 'string') {
23
23
  var msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
24
24
 
25
- bytes = new Array(msg.length);
25
+ bytes = new Uint8Array(msg.length);
26
26
 
27
- for (var i = 0; i < msg.length; i++) {
27
+ for (var i = 0; i < msg.length; ++i) {
28
28
  bytes[i] = msg.charCodeAt(i);
29
29
  }
30
30
  }
@@ -37,21 +37,26 @@ function md5(bytes) {
37
37
 
38
38
 
39
39
  function md5ToHexEncodedArray(input) {
40
- var i;
41
- var x;
42
40
  var output = [];
43
41
  var length32 = input.length * 32;
44
42
  var hexTab = '0123456789abcdef';
45
- var hex;
46
43
 
47
- for (i = 0; i < length32; i += 8) {
48
- x = input[i >> 5] >>> i % 32 & 0xff;
49
- hex = parseInt(hexTab.charAt(x >>> 4 & 0x0f) + hexTab.charAt(x & 0x0f), 16);
44
+ for (var i = 0; i < length32; i += 8) {
45
+ var x = input[i >> 5] >>> i % 32 & 0xff;
46
+ var hex = parseInt(hexTab.charAt(x >>> 4 & 0x0f) + hexTab.charAt(x & 0x0f), 16);
50
47
  output.push(hex);
51
48
  }
52
49
 
53
50
  return output;
54
51
  }
52
+ /**
53
+ * Calculate output length with padding and bit length
54
+ */
55
+
56
+
57
+ function getOutputLength(inputLength8) {
58
+ return (inputLength8 + 64 >>> 9 << 4) + 14 + 1;
59
+ }
55
60
  /*
56
61
  * Calculate the MD5 of an array of little-endian words, and a bit length.
57
62
  */
@@ -60,22 +65,17 @@ function md5ToHexEncodedArray(input) {
60
65
  function wordsToMd5(x, len) {
61
66
  /* append padding */
62
67
  x[len >> 5] |= 0x80 << len % 32;
63
- x[(len + 64 >>> 9 << 4) + 14] = len;
64
- var i;
65
- var olda;
66
- var oldb;
67
- var oldc;
68
- var oldd;
68
+ x[getOutputLength(len) - 1] = len;
69
69
  var a = 1732584193;
70
70
  var b = -271733879;
71
71
  var c = -1732584194;
72
72
  var d = 271733878;
73
73
 
74
- for (i = 0; i < x.length; i += 16) {
75
- olda = a;
76
- oldb = b;
77
- oldc = c;
78
- oldd = d;
74
+ for (var i = 0; i < x.length; i += 16) {
75
+ var olda = a;
76
+ var oldb = b;
77
+ var oldc = c;
78
+ var oldd = d;
79
79
  a = md5ff(a, b, c, d, x[i], 7, -680876936);
80
80
  d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);
81
81
  c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);
@@ -155,17 +155,14 @@ function wordsToMd5(x, len) {
155
155
 
156
156
 
157
157
  function bytesToWords(input) {
158
- var i;
159
- var output = [];
160
- output[(input.length >> 2) - 1] = undefined;
161
-
162
- for (i = 0; i < output.length; i += 1) {
163
- output[i] = 0;
158
+ if (input.length === 0) {
159
+ return [];
164
160
  }
165
161
 
166
162
  var length8 = input.length * 8;
163
+ var output = new Uint32Array(getOutputLength(length8));
167
164
 
168
- for (i = 0; i < length8; i += 8) {
165
+ for (var i = 0; i < length8; i += 8) {
169
166
  output[i >> 5] |= (input[i / 8] & 0xff) << i % 32;
170
167
  }
171
168
 
@@ -3,9 +3,8 @@
3
3
  // generators (like Math.random()).
4
4
  // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also,
5
5
  // find the complete implementation of crypto (msCrypto) on IE11.
6
- var getRandomValues = typeof crypto != 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto != 'undefined' && typeof msCrypto.getRandomValues == 'function' && msCrypto.getRandomValues.bind(msCrypto);
7
- var rnds8 = new Uint8Array(16); // eslint-disable-line no-undef
8
-
6
+ var getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);
7
+ var rnds8 = new Uint8Array(16);
9
8
  export default function rng() {
10
9
  if (!getRandomValues) {
11
10
  throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
@@ -24,13 +24,13 @@ function sha1(bytes) {
24
24
  var K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6];
25
25
  var H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
26
26
 
27
- if (typeof bytes == 'string') {
27
+ if (typeof bytes === 'string') {
28
28
  var msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
29
29
 
30
- bytes = new Array(msg.length);
30
+ bytes = [];
31
31
 
32
- for (var i = 0; i < msg.length; i++) {
33
- bytes[i] = msg.charCodeAt(i);
32
+ for (var i = 0; i < msg.length; ++i) {
33
+ bytes.push(msg.charCodeAt(i));
34
34
  }
35
35
  }
36
36
 
@@ -39,27 +39,29 @@ function sha1(bytes) {
39
39
  var N = Math.ceil(l / 16);
40
40
  var M = new Array(N);
41
41
 
42
- for (var i = 0; i < N; i++) {
43
- M[i] = new Array(16);
42
+ for (var _i = 0; _i < N; ++_i) {
43
+ var arr = new Uint32Array(16);
44
44
 
45
- for (var j = 0; j < 16; j++) {
46
- M[i][j] = bytes[i * 64 + j * 4] << 24 | bytes[i * 64 + j * 4 + 1] << 16 | bytes[i * 64 + j * 4 + 2] << 8 | bytes[i * 64 + j * 4 + 3];
45
+ for (var j = 0; j < 16; ++j) {
46
+ arr[j] = bytes[_i * 64 + j * 4] << 24 | bytes[_i * 64 + j * 4 + 1] << 16 | bytes[_i * 64 + j * 4 + 2] << 8 | bytes[_i * 64 + j * 4 + 3];
47
47
  }
48
+
49
+ M[_i] = arr;
48
50
  }
49
51
 
50
52
  M[N - 1][14] = (bytes.length - 1) * 8 / Math.pow(2, 32);
51
53
  M[N - 1][14] = Math.floor(M[N - 1][14]);
52
54
  M[N - 1][15] = (bytes.length - 1) * 8 & 0xffffffff;
53
55
 
54
- for (var i = 0; i < N; i++) {
55
- var W = new Array(80);
56
+ for (var _i2 = 0; _i2 < N; ++_i2) {
57
+ var W = new Uint32Array(80);
56
58
 
57
- for (var t = 0; t < 16; t++) {
58
- W[t] = M[i][t];
59
+ for (var t = 0; t < 16; ++t) {
60
+ W[t] = M[_i2][t];
59
61
  }
60
62
 
61
- for (var t = 16; t < 80; t++) {
62
- W[t] = ROTL(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1);
63
+ for (var _t = 16; _t < 80; ++_t) {
64
+ W[_t] = ROTL(W[_t - 3] ^ W[_t - 8] ^ W[_t - 14] ^ W[_t - 16], 1);
63
65
  }
64
66
 
65
67
  var a = H[0];
@@ -68,9 +70,9 @@ function sha1(bytes) {
68
70
  var d = H[3];
69
71
  var e = H[4];
70
72
 
71
- for (var t = 0; t < 80; t++) {
72
- var s = Math.floor(t / 20);
73
- var T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[t] >>> 0;
73
+ for (var _t2 = 0; _t2 < 80; ++_t2) {
74
+ var s = Math.floor(_t2 / 20);
75
+ var T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[_t2] >>> 0;
74
76
  e = d;
75
77
  d = c;
76
78
  c = ROTL(b, 30) >>> 0;
@@ -14,7 +14,7 @@ var _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details
14
14
 
15
15
  function v1(options, buf, offset) {
16
16
  var i = buf && offset || 0;
17
- var b = buf || [];
17
+ var b = buf || new Array(16);
18
18
  options = options || {};
19
19
  var node = options.node || _nodeId;
20
20
  var clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not
@@ -39,7 +39,7 @@ function v1(options, buf, offset) {
39
39
  // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
40
40
 
41
41
 
42
- var msecs = options.msecs !== undefined ? options.msecs : new Date().getTime(); // Per 4.2.1.2, use count of uuid's generated during the current clock
42
+ var msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock
43
43
  // cycle to simulate higher resolution clock
44
44
 
45
45
  var nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs)
@@ -89,7 +89,7 @@ function v1(options, buf, offset) {
89
89
  b[i + n] = node[n];
90
90
  }
91
91
 
92
- return buf ? buf : bytesToUuid(b);
92
+ return buf || bytesToUuid(b);
93
93
  }
94
94
 
95
95
  export default v1;