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 +70 -15
- package/CONTRIBUTING.md +2 -4
- package/LICENSE.md +3 -15
- package/README.md +46 -50
- package/dist/bytesToUuid.js +7 -7
- package/dist/esm-browser/bytesToUuid.js +5 -5
- package/dist/esm-browser/md5.js +24 -27
- package/dist/esm-browser/rng.js +2 -3
- package/dist/esm-browser/sha1.js +19 -17
- package/dist/esm-browser/v1.js +3 -3
- package/dist/esm-browser/v35.js +29 -14
- package/dist/esm-browser/v4.js +7 -10
- package/dist/esm-node/bytesToUuid.js +7 -7
- package/dist/esm-node/rng.js +2 -1
- package/dist/esm-node/v1.js +16 -16
- package/dist/esm-node/v35.js +32 -17
- package/dist/esm-node/v4.js +8 -11
- package/dist/md5-browser.js +39 -40
- package/dist/rng-browser.js +2 -2
- package/dist/rng.js +3 -1
- package/dist/sha1-browser.js +31 -25
- package/dist/umd/uuid.min.js +1 -1
- package/dist/umd/uuidv1.min.js +1 -1
- package/dist/umd/uuidv3.min.js +1 -1
- package/dist/umd/uuidv4.min.js +1 -1
- package/dist/umd/uuidv5.min.js +1 -1
- package/dist/uuid-bin.js +36 -18
- package/dist/v1.js +16 -16
- package/dist/v35.js +32 -17
- package/dist/v4.js +8 -11
- package/package.json +40 -26
package/dist/umd/uuidv1.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o():"function"==typeof define&&define.amd?define(o):(e=e||self).uuidv1=o()}(this,(function(){"use strict";var e="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto),o=new Uint8Array(16);function n(){if(!e)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return e(o)}for(var t,r,u=[],s=0;s<256;++s)u
|
|
1
|
+
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o():"function"==typeof define&&define.amd?define(o):(e=e||self).uuidv1=o()}(this,(function(){"use strict";var e="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto),o=new Uint8Array(16);function n(){if(!e)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return e(o)}for(var t,r,u=[],s=0;s<256;++s)u.push((s+256).toString(16).substr(1));var d=0,i=0;return function(e,o,s){var a=o&&s||0,c=o||new Array(16),f=(e=e||{}).node||t,p=void 0!==e.clockseq?e.clockseq:r;if(null==f||null==p){var l=e.random||(e.rng||n)();null==f&&(f=t=[1|l[0],l[1],l[2],l[3],l[4],l[5]]),null==p&&(p=r=16383&(l[6]<<8|l[7]))}var m=void 0!==e.msecs?e.msecs:Date.now(),v=void 0!==e.nsecs?e.nsecs:i+1,y=m-d+(v-i)/1e4;if(y<0&&void 0===e.clockseq&&(p=p+1&16383),(y<0||m>d)&&void 0===e.nsecs&&(v=0),v>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");d=m,i=v,r=p;var g=(1e4*(268435455&(m+=122192928e5))+v)%4294967296;c[a++]=g>>>24&255,c[a++]=g>>>16&255,c[a++]=g>>>8&255,c[a++]=255&g;var w=m/4294967296*1e4&268435455;c[a++]=w>>>8&255,c[a++]=255&w,c[a++]=w>>>24&15|16,c[a++]=w>>>16&255,c[a++]=p>>>8|128,c[a++]=255&p;for(var h=0;h<6;++h)c[a+h]=f[h];return o||function(e,o){var n=o||0;return(u[e[n+0]]+u[e[n+1]]+u[e[n+2]]+u[e[n+3]]+"-"+u[e[n+4]]+u[e[n+5]]+"-"+u[e[n+6]]+u[e[n+7]]+"-"+u[e[n+8]]+u[e[n+9]]+"-"+u[e[n+10]]+u[e[n+11]]+u[e[n+12]]+u[e[n+13]]+u[e[n+14]]+u[e[n+15]]).toLowerCase()}(c)}}));
|
package/dist/umd/uuidv3.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(r,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(r=r||self).uuidv3=n()}(this,(function(){"use strict";for(var r=[],n=0;n<256;++n)r
|
|
1
|
+
!function(r,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(r=r||self).uuidv3=n()}(this,(function(){"use strict";for(var r=[],n=0;n<256;++n)r.push((n+256).toString(16).substr(1));function t(r){return 14+(r+64>>>9<<4)+1}function e(r,n){var t=(65535&r)+(65535&n);return(r>>16)+(n>>16)+(t>>16)<<16|65535&t}function u(r,n,t,u,o,a){return e((f=e(e(n,r),e(u,a)))<<(c=o)|f>>>32-c,t);var f,c}function o(r,n,t,e,o,a,f){return u(n&t|~n&e,r,n,o,a,f)}function a(r,n,t,e,o,a,f){return u(n&e|t&~e,r,n,o,a,f)}function f(r,n,t,e,o,a,f){return u(n^t^e,r,n,o,a,f)}function c(r,n,t,e,o,a,f){return u(t^(n|~e),r,n,o,a,f)}return function(n,t,e){function u(n,u,o,a){if("string"==typeof n&&(n=function(r){r=unescape(encodeURIComponent(r));for(var n=[],t=0;t<r.length;++t)n.push(r.charCodeAt(t));return n}(n)),"string"==typeof u&&(u=function(r){var n=[];return r.replace(/[a-fA-F0-9]{2}/g,(function(r){n.push(parseInt(r,16))})),n}(u)),!Array.isArray(n))throw TypeError("value must be an array of bytes");if(!Array.isArray(u)||16!==u.length)throw TypeError("namespace must be uuid string or an Array of 16 byte values");var f=e(u.concat(n));if(f[6]=15&f[6]|t,f[8]=63&f[8]|128,o){a=a||0;for(var c=0;c<16;++c)o[a+c]=f[c];return o}return function(n,t){var e=t||0;return(r[n[e+0]]+r[n[e+1]]+r[n[e+2]]+r[n[e+3]]+"-"+r[n[e+4]]+r[n[e+5]]+"-"+r[n[e+6]]+r[n[e+7]]+"-"+r[n[e+8]]+r[n[e+9]]+"-"+r[n[e+10]]+r[n[e+11]]+r[n[e+12]]+r[n[e+13]]+r[n[e+14]]+r[n[e+15]]).toLowerCase()}(f)}try{u.name=n}catch(r){}return u.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",u.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",u}("v3",48,(function(r){if("string"==typeof r){var n=unescape(encodeURIComponent(r));r=new Uint8Array(n.length);for(var u=0;u<n.length;++u)r[u]=n.charCodeAt(u)}return function(r){for(var n=[],t=32*r.length,e=0;e<t;e+=8){var u=r[e>>5]>>>e%32&255,o=parseInt("0123456789abcdef".charAt(u>>>4&15)+"0123456789abcdef".charAt(15&u),16);n.push(o)}return n}(function(r,n){r[n>>5]|=128<<n%32,r[t(n)-1]=n;for(var u=1732584193,i=-271733879,s=-1732584194,d=271733878,p=0;p<r.length;p+=16){var h=u,v=i,y=s,g=d;u=o(u,i,s,d,r[p],7,-680876936),d=o(d,u,i,s,r[p+1],12,-389564586),s=o(s,d,u,i,r[p+2],17,606105819),i=o(i,s,d,u,r[p+3],22,-1044525330),u=o(u,i,s,d,r[p+4],7,-176418897),d=o(d,u,i,s,r[p+5],12,1200080426),s=o(s,d,u,i,r[p+6],17,-1473231341),i=o(i,s,d,u,r[p+7],22,-45705983),u=o(u,i,s,d,r[p+8],7,1770035416),d=o(d,u,i,s,r[p+9],12,-1958414417),s=o(s,d,u,i,r[p+10],17,-42063),i=o(i,s,d,u,r[p+11],22,-1990404162),u=o(u,i,s,d,r[p+12],7,1804603682),d=o(d,u,i,s,r[p+13],12,-40341101),s=o(s,d,u,i,r[p+14],17,-1502002290),i=o(i,s,d,u,r[p+15],22,1236535329),u=a(u,i,s,d,r[p+1],5,-165796510),d=a(d,u,i,s,r[p+6],9,-1069501632),s=a(s,d,u,i,r[p+11],14,643717713),i=a(i,s,d,u,r[p],20,-373897302),u=a(u,i,s,d,r[p+5],5,-701558691),d=a(d,u,i,s,r[p+10],9,38016083),s=a(s,d,u,i,r[p+15],14,-660478335),i=a(i,s,d,u,r[p+4],20,-405537848),u=a(u,i,s,d,r[p+9],5,568446438),d=a(d,u,i,s,r[p+14],9,-1019803690),s=a(s,d,u,i,r[p+3],14,-187363961),i=a(i,s,d,u,r[p+8],20,1163531501),u=a(u,i,s,d,r[p+13],5,-1444681467),d=a(d,u,i,s,r[p+2],9,-51403784),s=a(s,d,u,i,r[p+7],14,1735328473),i=a(i,s,d,u,r[p+12],20,-1926607734),u=f(u,i,s,d,r[p+5],4,-378558),d=f(d,u,i,s,r[p+8],11,-2022574463),s=f(s,d,u,i,r[p+11],16,1839030562),i=f(i,s,d,u,r[p+14],23,-35309556),u=f(u,i,s,d,r[p+1],4,-1530992060),d=f(d,u,i,s,r[p+4],11,1272893353),s=f(s,d,u,i,r[p+7],16,-155497632),i=f(i,s,d,u,r[p+10],23,-1094730640),u=f(u,i,s,d,r[p+13],4,681279174),d=f(d,u,i,s,r[p],11,-358537222),s=f(s,d,u,i,r[p+3],16,-722521979),i=f(i,s,d,u,r[p+6],23,76029189),u=f(u,i,s,d,r[p+9],4,-640364487),d=f(d,u,i,s,r[p+12],11,-421815835),s=f(s,d,u,i,r[p+15],16,530742520),i=f(i,s,d,u,r[p+2],23,-995338651),u=c(u,i,s,d,r[p],6,-198630844),d=c(d,u,i,s,r[p+7],10,1126891415),s=c(s,d,u,i,r[p+14],15,-1416354905),i=c(i,s,d,u,r[p+5],21,-57434055),u=c(u,i,s,d,r[p+12],6,1700485571),d=c(d,u,i,s,r[p+3],10,-1894986606),s=c(s,d,u,i,r[p+10],15,-1051523),i=c(i,s,d,u,r[p+1],21,-2054922799),u=c(u,i,s,d,r[p+8],6,1873313359),d=c(d,u,i,s,r[p+15],10,-30611744),s=c(s,d,u,i,r[p+6],15,-1560198380),i=c(i,s,d,u,r[p+13],21,1309151649),u=c(u,i,s,d,r[p+4],6,-145523070),d=c(d,u,i,s,r[p+11],10,-1120210379),s=c(s,d,u,i,r[p+2],15,718787259),i=c(i,s,d,u,r[p+9],21,-343485551),u=e(u,h),i=e(i,v),s=e(s,y),d=e(d,g)}return[u,i,s,d]}(function(r){if(0===r.length)return[];for(var n=8*r.length,e=new Uint32Array(t(n)),u=0;u<n;u+=8)e[u>>5]|=(255&r[u/8])<<u%32;return e}(r),8*r.length))}))}));
|
package/dist/umd/uuidv4.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).uuidv4=e()}(this,(function(){"use strict";var t="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto),e=new Uint8Array(16);function
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).uuidv4=e()}(this,(function(){"use strict";var t="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto),e=new Uint8Array(16);function o(){if(!t)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return t(e)}for(var n=[],r=0;r<256;++r)n.push((r+256).toString(16).substr(1));return function(t,e,r){var u=(t=t||{}).random||(t.rng||o)();if(u[6]=15&u[6]|64,u[8]=63&u[8]|128,e){r=r||0;for(var d=0;d<16;++d)e[r+d]=u[d];return e}return function(t,e){var o=e||0;return(n[t[o+0]]+n[t[o+1]]+n[t[o+2]]+n[t[o+3]]+"-"+n[t[o+4]]+n[t[o+5]]+"-"+n[t[o+6]]+n[t[o+7]]+"-"+n[t[o+8]]+n[t[o+9]]+"-"+n[t[o+10]]+n[t[o+11]]+n[t[o+12]]+n[t[o+13]]+n[t[o+14]]+n[t[o+15]]).toLowerCase()}(u)}}));
|
package/dist/umd/uuidv5.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(r=r||self).uuidv5=e()}(this,(function(){"use strict";for(var r=[],e=0;e<256;++e)r
|
|
1
|
+
!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(r=r||self).uuidv5=e()}(this,(function(){"use strict";for(var r=[],e=0;e<256;++e)r.push((e+256).toString(16).substr(1));function n(r,e,n,t){switch(r){case 0:return e&n^~e&t;case 1:return e^n^t;case 2:return e&n^e&t^n&t;case 3:return e^n^t}}function t(r,e){return r<<e|r>>>32-e}return function(e,n,t){function o(e,o,a,u){if("string"==typeof e&&(e=function(r){r=unescape(encodeURIComponent(r));for(var e=[],n=0;n<r.length;++n)e.push(r.charCodeAt(n));return e}(e)),"string"==typeof o&&(o=function(r){var e=[];return r.replace(/[a-fA-F0-9]{2}/g,(function(r){e.push(parseInt(r,16))})),e}(o)),!Array.isArray(e))throw TypeError("value must be an array of bytes");if(!Array.isArray(o)||16!==o.length)throw TypeError("namespace must be uuid string or an Array of 16 byte values");var f=t(o.concat(e));if(f[6]=15&f[6]|n,f[8]=63&f[8]|128,a){u=u||0;for(var c=0;c<16;++c)a[u+c]=f[c];return a}return function(e,n){var t=n||0;return(r[e[t+0]]+r[e[t+1]]+r[e[t+2]]+r[e[t+3]]+"-"+r[e[t+4]]+r[e[t+5]]+"-"+r[e[t+6]]+r[e[t+7]]+"-"+r[e[t+8]]+r[e[t+9]]+"-"+r[e[t+10]]+r[e[t+11]]+r[e[t+12]]+r[e[t+13]]+r[e[t+14]]+r[e[t+15]]).toLowerCase()}(f)}try{o.name=e}catch(r){}return o.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",o.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",o}("v5",80,(function(r){var e=[1518500249,1859775393,2400959708,3395469782],o=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof r){var a=unescape(encodeURIComponent(r));r=[];for(var u=0;u<a.length;++u)r.push(a.charCodeAt(u))}r.push(128);for(var f=r.length/4+2,c=Math.ceil(f/16),i=new Array(c),s=0;s<c;++s){for(var p=new Uint32Array(16),d=0;d<16;++d)p[d]=r[64*s+4*d]<<24|r[64*s+4*d+1]<<16|r[64*s+4*d+2]<<8|r[64*s+4*d+3];i[s]=p}i[c-1][14]=8*(r.length-1)/Math.pow(2,32),i[c-1][14]=Math.floor(i[c-1][14]),i[c-1][15]=8*(r.length-1)&4294967295;for(var h=0;h<c;++h){for(var v=new Uint32Array(80),y=0;y<16;++y)v[y]=i[h][y];for(var l=16;l<80;++l)v[l]=t(v[l-3]^v[l-8]^v[l-14]^v[l-16],1);for(var b=o[0],g=o[1],A=o[2],m=o[3],w=o[4],C=0;C<80;++C){var U=Math.floor(C/20),M=t(b,5)+n(U,g,A,m)+w+e[U]+v[C]>>>0;w=m,m=A,A=t(g,30)>>>0,g=b,b=M}o[0]=o[0]+b>>>0,o[1]=o[1]+g>>>0,o[2]=o[2]+A>>>0,o[3]=o[3]+m>>>0,o[4]=o[4]+w>>>0}return[o[0]>>24&255,o[0]>>16&255,o[0]>>8&255,255&o[0],o[1]>>24&255,o[1]>>16&255,o[1]>>8&255,255&o[1],o[2]>>24&255,o[2]>>16&255,o[2]>>8&255,255&o[2],o[3]>>24&255,o[3]>>16&255,o[3]>>8&255,255&o[3],o[4]>>24&255,o[4]>>16&255,o[4]>>8&255,255&o[4]]}))}));
|
package/dist/uuid-bin.js
CHANGED
|
@@ -23,14 +23,14 @@ function usage() {
|
|
|
23
23
|
console.log('\nNote: <namespace uuid> may be "URL" or "DNS" to use the corresponding UUIDs defined by RFC4122');
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
const args = process.argv.slice(2);
|
|
27
27
|
|
|
28
28
|
if (args.indexOf('--help') >= 0) {
|
|
29
29
|
usage();
|
|
30
30
|
process.exit(0);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
const version = args.shift() || 'v4';
|
|
34
34
|
|
|
35
35
|
switch (version) {
|
|
36
36
|
case 'v1':
|
|
@@ -38,28 +38,46 @@ switch (version) {
|
|
|
38
38
|
break;
|
|
39
39
|
|
|
40
40
|
case 'v3':
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
{
|
|
42
|
+
const name = args.shift();
|
|
43
|
+
let namespace = args.shift();
|
|
44
|
+
(0, _assert.default)(name != null, 'v3 name not specified');
|
|
45
|
+
(0, _assert.default)(namespace != null, 'v3 namespace not specified');
|
|
46
|
+
|
|
47
|
+
if (namespace === 'URL') {
|
|
48
|
+
namespace = _v2.default.URL;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (namespace === 'DNS') {
|
|
52
|
+
namespace = _v2.default.DNS;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
console.log((0, _v2.default)(name, namespace));
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
49
58
|
|
|
50
59
|
case 'v4':
|
|
51
60
|
console.log((0, _v3.default)());
|
|
52
61
|
break;
|
|
53
62
|
|
|
54
63
|
case 'v5':
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
{
|
|
65
|
+
const name = args.shift();
|
|
66
|
+
let namespace = args.shift();
|
|
67
|
+
(0, _assert.default)(name != null, 'v5 name not specified');
|
|
68
|
+
(0, _assert.default)(namespace != null, 'v5 namespace not specified');
|
|
69
|
+
|
|
70
|
+
if (namespace === 'URL') {
|
|
71
|
+
namespace = _v4.default.URL;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (namespace === 'DNS') {
|
|
75
|
+
namespace = _v4.default.DNS;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
console.log((0, _v4.default)(name, namespace));
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
63
81
|
|
|
64
82
|
default:
|
|
65
83
|
usage();
|
package/dist/v1.js
CHANGED
|
@@ -15,25 +15,25 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
15
15
|
//
|
|
16
16
|
// Inspired by https://github.com/LiosK/UUID.js
|
|
17
17
|
// and http://docs.python.org/library/uuid.html
|
|
18
|
-
|
|
18
|
+
let _nodeId;
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
let _clockseq; // Previous uuid creation time
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
let _lastMSecs = 0;
|
|
24
|
+
let _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details
|
|
25
25
|
|
|
26
26
|
function v1(options, buf, offset) {
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
let i = buf && offset || 0;
|
|
28
|
+
const b = buf || new Array(16);
|
|
29
29
|
options = options || {};
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
let node = options.node || _nodeId;
|
|
31
|
+
let clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not
|
|
32
32
|
// specified. We do this lazily to minimize issues related to insufficient
|
|
33
33
|
// system entropy. See #189
|
|
34
34
|
|
|
35
35
|
if (node == null || clockseq == null) {
|
|
36
|
-
|
|
36
|
+
const seedBytes = options.random || (options.rng || _rng.default)();
|
|
37
37
|
|
|
38
38
|
if (node == null) {
|
|
39
39
|
// Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)
|
|
@@ -50,12 +50,12 @@ function v1(options, buf, offset) {
|
|
|
50
50
|
// (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
|
|
51
51
|
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
let msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock
|
|
54
54
|
// cycle to simulate higher resolution clock
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
let nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs)
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression
|
|
59
59
|
|
|
60
60
|
if (dt < 0 && options.clockseq === undefined) {
|
|
61
61
|
clockseq = clockseq + 1 & 0x3fff;
|
|
@@ -78,13 +78,13 @@ function v1(options, buf, offset) {
|
|
|
78
78
|
|
|
79
79
|
msecs += 12219292800000; // `time_low`
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
const tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
|
|
82
82
|
b[i++] = tl >>> 24 & 0xff;
|
|
83
83
|
b[i++] = tl >>> 16 & 0xff;
|
|
84
84
|
b[i++] = tl >>> 8 & 0xff;
|
|
85
85
|
b[i++] = tl & 0xff; // `time_mid`
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
const tmh = msecs / 0x100000000 * 10000 & 0xfffffff;
|
|
88
88
|
b[i++] = tmh >>> 8 & 0xff;
|
|
89
89
|
b[i++] = tmh & 0xff; // `time_high_and_version`
|
|
90
90
|
|
|
@@ -96,11 +96,11 @@ function v1(options, buf, offset) {
|
|
|
96
96
|
|
|
97
97
|
b[i++] = clockseq & 0xff; // `node`
|
|
98
98
|
|
|
99
|
-
for (
|
|
99
|
+
for (let n = 0; n < 6; ++n) {
|
|
100
100
|
b[i + n] = node[n];
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
return buf
|
|
103
|
+
return buf || (0, _bytesToUuid.default)(b);
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
var _default = v1;
|
package/dist/v35.js
CHANGED
|
@@ -12,7 +12,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
12
12
|
|
|
13
13
|
function uuidToBytes(uuid) {
|
|
14
14
|
// Note: We assume we're being passed a valid uuid string
|
|
15
|
-
|
|
15
|
+
const bytes = [];
|
|
16
16
|
uuid.replace(/[a-fA-F0-9]{2}/g, function (hex) {
|
|
17
17
|
bytes.push(parseInt(hex, 16));
|
|
18
18
|
});
|
|
@@ -22,10 +22,10 @@ function uuidToBytes(uuid) {
|
|
|
22
22
|
function stringToBytes(str) {
|
|
23
23
|
str = unescape(encodeURIComponent(str)); // UTF8 escape
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
const bytes = [];
|
|
26
26
|
|
|
27
|
-
for (
|
|
28
|
-
bytes
|
|
27
|
+
for (let i = 0; i < str.length; ++i) {
|
|
28
|
+
bytes.push(str.charCodeAt(i));
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
return bytes;
|
|
@@ -37,29 +37,44 @@ const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
|
|
|
37
37
|
exports.URL = URL;
|
|
38
38
|
|
|
39
39
|
function _default(name, version, hashfunc) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (
|
|
46
|
-
|
|
47
|
-
|
|
40
|
+
function generateUUID(value, namespace, buf, offset) {
|
|
41
|
+
if (typeof value === 'string') {
|
|
42
|
+
value = stringToBytes(value);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (typeof namespace === 'string') {
|
|
46
|
+
namespace = uuidToBytes(namespace);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (!Array.isArray(value)) {
|
|
50
|
+
throw TypeError('value must be an array of bytes');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (!Array.isArray(namespace) || namespace.length !== 16) {
|
|
54
|
+
throw TypeError('namespace must be uuid string or an Array of 16 byte values');
|
|
55
|
+
} // Per 4.3
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
const bytes = hashfunc(namespace.concat(value));
|
|
48
59
|
bytes[6] = bytes[6] & 0x0f | version;
|
|
49
60
|
bytes[8] = bytes[8] & 0x3f | 0x80;
|
|
50
61
|
|
|
51
62
|
if (buf) {
|
|
52
|
-
|
|
53
|
-
|
|
63
|
+
offset = offset || 0;
|
|
64
|
+
|
|
65
|
+
for (let i = 0; i < 16; ++i) {
|
|
66
|
+
buf[offset + i] = bytes[i];
|
|
54
67
|
}
|
|
68
|
+
|
|
69
|
+
return buf;
|
|
55
70
|
}
|
|
56
71
|
|
|
57
|
-
return
|
|
58
|
-
}
|
|
72
|
+
return (0, _bytesToUuid.default)(bytes);
|
|
73
|
+
} // Function#name is not settable on some platforms (#270)
|
|
59
74
|
|
|
60
75
|
|
|
61
76
|
try {
|
|
62
|
-
generateUUID.name = name;
|
|
77
|
+
generateUUID.name = name; // eslint-disable-next-line no-empty
|
|
63
78
|
} catch (err) {} // For CommonJS default export support
|
|
64
79
|
|
|
65
80
|
|
package/dist/v4.js
CHANGED
|
@@ -12,28 +12,25 @@ var _bytesToUuid = _interopRequireDefault(require("./bytesToUuid.js"));
|
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
13
|
|
|
14
14
|
function v4(options, buf, offset) {
|
|
15
|
-
var i = buf && offset || 0;
|
|
16
|
-
|
|
17
|
-
if (typeof options == 'string') {
|
|
18
|
-
buf = options === 'binary' ? new Array(16) : null;
|
|
19
|
-
options = null;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
15
|
options = options || {};
|
|
23
16
|
|
|
24
|
-
|
|
17
|
+
const rnds = options.random || (options.rng || _rng.default)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
25
18
|
|
|
26
19
|
|
|
27
20
|
rnds[6] = rnds[6] & 0x0f | 0x40;
|
|
28
21
|
rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
|
|
29
22
|
|
|
30
23
|
if (buf) {
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
offset = offset || 0;
|
|
25
|
+
|
|
26
|
+
for (let i = 0; i < 16; ++i) {
|
|
27
|
+
buf[offset + i] = rnds[i];
|
|
33
28
|
}
|
|
29
|
+
|
|
30
|
+
return buf;
|
|
34
31
|
}
|
|
35
32
|
|
|
36
|
-
return
|
|
33
|
+
return (0, _bytesToUuid.default)(rnds);
|
|
37
34
|
}
|
|
38
35
|
|
|
39
36
|
var _default = v4;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uuid",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.2.0",
|
|
4
4
|
"description": "RFC4122 (v1, v4, and v5) UUIDs",
|
|
5
5
|
"commitlint": {
|
|
6
6
|
"extends": [
|
|
@@ -19,8 +19,15 @@
|
|
|
19
19
|
"sideEffects": false,
|
|
20
20
|
"main": "./dist/index.js",
|
|
21
21
|
"exports": {
|
|
22
|
-
"
|
|
23
|
-
|
|
22
|
+
".": {
|
|
23
|
+
"node": {
|
|
24
|
+
"module": "./dist/esm-node/index.js",
|
|
25
|
+
"require": "./dist/index.js",
|
|
26
|
+
"import": "./wrapper.mjs"
|
|
27
|
+
},
|
|
28
|
+
"default": "./dist/esm-browser/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./package.json": "./package.json"
|
|
24
31
|
},
|
|
25
32
|
"module": "./dist/esm-node/index.js",
|
|
26
33
|
"browser": {
|
|
@@ -38,33 +45,38 @@
|
|
|
38
45
|
"wrapper.mjs"
|
|
39
46
|
],
|
|
40
47
|
"devDependencies": {
|
|
41
|
-
"@babel/cli": "7.
|
|
42
|
-
"@babel/core": "7.
|
|
43
|
-
"@babel/preset-env": "7.
|
|
44
|
-
"@commitlint/cli": "
|
|
45
|
-
"@commitlint/config-conventional": "
|
|
46
|
-
"@rollup/plugin-node-resolve": "
|
|
47
|
-
"@wdio/browserstack-service": "6.
|
|
48
|
-
"@wdio/cli": "6.
|
|
49
|
-
"@wdio/jasmine-framework": "6.
|
|
50
|
-
"@wdio/local-runner": "6.
|
|
51
|
-
"@wdio/spec-reporter": "6.
|
|
52
|
-
"@wdio/static-server-service": "6.
|
|
53
|
-
"@wdio/sync": "6.
|
|
48
|
+
"@babel/cli": "7.10.3",
|
|
49
|
+
"@babel/core": "7.10.3",
|
|
50
|
+
"@babel/preset-env": "7.10.3",
|
|
51
|
+
"@commitlint/cli": "9.0.1",
|
|
52
|
+
"@commitlint/config-conventional": "9.0.1",
|
|
53
|
+
"@rollup/plugin-node-resolve": "8.0.1",
|
|
54
|
+
"@wdio/browserstack-service": "6.1.15",
|
|
55
|
+
"@wdio/cli": "6.1.20",
|
|
56
|
+
"@wdio/jasmine-framework": "6.1.17",
|
|
57
|
+
"@wdio/local-runner": "6.1.20",
|
|
58
|
+
"@wdio/spec-reporter": "6.1.14",
|
|
59
|
+
"@wdio/static-server-service": "6.1.14",
|
|
60
|
+
"@wdio/sync": "6.1.14",
|
|
54
61
|
"babel-eslint": "10.1.0",
|
|
55
|
-
"bundlewatch": "0.2.
|
|
56
|
-
"eslint": "
|
|
57
|
-
"eslint-config-prettier": "6.
|
|
58
|
-
"eslint-
|
|
62
|
+
"bundlewatch": "0.2.7",
|
|
63
|
+
"eslint": "7.3.0",
|
|
64
|
+
"eslint-config-prettier": "6.11.0",
|
|
65
|
+
"eslint-config-standard": "14.1.1",
|
|
66
|
+
"eslint-plugin-import": "2.21.2",
|
|
67
|
+
"eslint-plugin-node": "11.1.0",
|
|
68
|
+
"eslint-plugin-prettier": "3.1.4",
|
|
69
|
+
"eslint-plugin-promise": "4.2.1",
|
|
70
|
+
"eslint-plugin-standard": "4.0.1",
|
|
59
71
|
"husky": "4.2.5",
|
|
60
|
-
"jest": "25.
|
|
61
|
-
"lint-staged": "10.
|
|
72
|
+
"jest": "25.5.4",
|
|
73
|
+
"lint-staged": "10.2.11",
|
|
62
74
|
"npm-run-all": "4.1.5",
|
|
63
|
-
"prettier": "2.0.
|
|
64
|
-
"rollup": "2.
|
|
65
|
-
"rollup-plugin-terser": "
|
|
75
|
+
"prettier": "2.0.5",
|
|
76
|
+
"rollup": "2.18.0",
|
|
77
|
+
"rollup-plugin-terser": "6.1.0",
|
|
66
78
|
"runmd": "1.3.2",
|
|
67
|
-
"standard-version": "
|
|
79
|
+
"standard-version": "8.0.0"
|
|
68
80
|
},
|
|
69
81
|
"scripts": {
|
|
70
82
|
"examples:browser:webpack:build": "cd examples/browser-webpack && npm install && npm run build",
|
|
@@ -81,6 +93,8 @@
|
|
|
81
93
|
"pretest:node": "npm run build",
|
|
82
94
|
"test:node": "npm-run-all --parallel examples:node:**",
|
|
83
95
|
"test:pack": "./scripts/testpack.sh",
|
|
96
|
+
"pretest:benchmark": "npm run build",
|
|
97
|
+
"test:benchmark": "cd examples/benchmark && npm install && npm test",
|
|
84
98
|
"prettier:check": "prettier --ignore-path .prettierignore --check '**/*.{js,jsx,json,md}'",
|
|
85
99
|
"prettier:fix": "prettier --ignore-path .prettierignore --write '**/*.{js,jsx,json,md}'",
|
|
86
100
|
"bundlewatch": "npm run pretest:browser && bundlewatch --config bundlewatch.config.json",
|