Comparing version 0.1.7 to 0.1.8
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.ifid=t():e.ifid=t()}(global,function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=4)}([function(e,t){e.exports=require("os")},function(e,t){e.exports=require("crypto")},function(e,t){e.exports=require("fs")},function(e,t){e.exports=require("path")},function(e,t,r){"use strict";var n;r.r(t),function(e){e.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",e.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",e.OID="6ba7b812-9dad-11d1-80b4-00c04fd430c8",e.X500="6ba7b814-9dad-11d1-80b4-00c04fd430c8"}(n||(n={}));var i=function(e){for(var t=[],r=e.length;r>0;r-=8){var n=e.slice(r-8,r).padStart(8,"0");t.unshift(parseInt(n,2))}return new Uint8Array(t)},o=r(1),a={BIT_ARRAY_INVALID:"The array of bits was not an array, had no contents, or had one or more items which did not meet the isBit type guard.",UUID_VERSION_INVALID:"The version argument was not a valid UUID version.",TIMESTAMP_GENERATION_FAILED:"The random number generator did not produce an acceptable value for the random number used in place of a stable timestamp.",TIMESTAMP_INVALID:"The timestamp property of the UUID object is malformed.",NAMESPACE_ID_MISSING:"In order to construct a v3 or v5 UUID, you need to provide a namespace ID to be hashed.",NAME_MISSING:"In order to construct a v3 or v5 UUID, you need to provide a name to be hashed.",CLOCK_SEQUENCE_INVALID:"The clockSequence property of the UUID object is malformed.",CLOCK_SEQUENCE_GENERATION_FAILED:"The random number generator did not produce an acceptable value for the random number used in place of a stable clock sequence.",CLOCK_SEQUENCE_LOW_INVALID:"The clockSequenceLow property of the UUID object is malformed.",CLOCK_SEQUENCE_HIGH_INVALID:"The clockSequenceHigh property of the UUID object is malformed.",CLOCK_HIGH_AND_RESERVED_INVALID:"The clockSequenceHighAndReserved property of the UUID object is malformed.",MAC_ADDRESS_UNAVAILABLE:"The MAC address is unavailable, which makes creating the version 1 node ID impossible.",MAC_ADDRESS_INVALID:"The MAC address was found, but it was malformed.",UUID_LAST_RESULTS_INVALID:"The provided last results object did not meet the isValidLastResults type guard.",UUID_STRING_INVALID:"The text argument passed to UUID.parse was malformed.",UUID_OPTIONS_INVALID:"The options argument passed to one of the UUID methods did not meet the isUUIDOptions type guard.",TIME_LOW_INVALID:"The timestamp property did not produce a valid low portion of the timestamp.",TIME_MID_INVALID:"The timestamp property did not produce a valid mid portion of the timestamp.",TIME_HIGH_INVALID:"The timestamp property did not produce a valid high portion of the timestamp.",TIME_HIGH_AND_VERSION_INVALID:"The timestamp property did not produce a valid high-and-version multiplex.",NODE_IDENTIFIER_INVALID:"The nodeIdentifier property of the UUID object was malformed."},c=function(e,t,r){if(!t)throw new Error(a.NAMESPACE_ID_MISSING);if(!r)throw new Error(a.NAME_MISSING);var n;n="3"===e.toString()?Object(o.createHash)("md5"):Object(o.createHash)("sha1");var i=t.split("-").map(function(e){var t=e.length;return parseInt(parseInt(e,16).toString(2).split("").reverse().join(""),2).toString(16).padEnd(t,"0")}).join("-");return n.update(i+r),n.digest("hex")};function s(e){return/^[1345]$/.test(e.toString())}var u=r(2);function d(e){return"object"==typeof e&&e&&e.clockSequence&&"BYTES_PER_ELEMENT"in e.clockSequence&&e.nodeIdentifier&&"BYTES_PER_ELEMENT"in e.nodeIdentifier&&e.timestamp&&"BYTES_PER_ELEMENT"in e.timestamp}var f=r(0),p=r(3),I=function(){var e=null;try{var t=Object(u.readFileSync)(Object(p.join)(Object(f.homedir)(),"ifid"),"utf8");e=JSON.parse(t)}catch(e){}return d(e)?e:{}}(),m=function(){return Boolean("undefined"!=typeof process&&process.versions&&process.versions.node)},l=function(e){if(m())return new Uint8Array(Object(o.randomBytes)(e));for(var t=t||msCrypto,r=new Uint8Array(e),n=0;n<e;n+=65536)t.getRandomValues(r.subarray(n,n+Math.min(e-n,65536)));return r},S=function(e){return parseInt(Buffer.from(e).toString("hex"),16)};function h(e,t,r){if(!s(e))throw new Error(a.UUID_VERSION_INVALID);var n;if(/^[14]$/.test(e.toString())){if(I.clockSequence&&"BYTES_PER_ELEMENT"in I.clockSequence)return I.clockSequence;n=function(){var e=S(l(2)).toString(2).slice(0,14);return new Uint8Array([parseInt(e.slice(0,6),2),parseInt(e.slice(6),2)])}(),"1"===e.toString()&&(I.clockSequence=n)}else{var o=c(e,t,r),u="";u+=o.slice(16,18),u+=o.slice(18,20);var d=parseInt(u,16).toString(2).padStart(14,"0");n=i(d)}return n}function _(){for(var e=Object(f.networkInterfaces)(),t=Object.keys(e),r=0;r<t.length;r+=1)for(var n=e[t[r]],i=0;i<n.length;i+=1){var o=n[i];if("object"==typeof o&&o){var c=o.mac;if("string"==typeof c&&c&&"00:00:00:00:00:00"!==c){var s=c.split(":").map(function(e){return parseInt(e,16)});return new Uint8Array(s)}}}throw new Error(a.MAC_ADDRESS_UNAVAILABLE)}function v(e,t,r){var n;if("1"===e.toString()){if(I.nodeIdentifier&&"BYTES_PER_ELEMENT"in I.nodeIdentifier)return I.nodeIdentifier;n=_(),I.nodeIdentifier=n}else if(/^[35]$/.test(e.toString())){var o="";o+=c(e,t,r).slice(20,32);var s=parseInt(o,16).toString(2).padStart(48,"0");n=i(s)}else{if("4"!==e.toString())throw new Error(a.UUID_VERSION_INVALID);n=l(6)}return n}function E(){return 10*((new Date).getTime()-new Date(1582,9,15).getTime())}function g(e,t,r){if(!s(e))throw new Error(a.UUID_VERSION_INVALID);var n;if("1"===e.toString()){var o=I.timestamp,u=E();o&&"BYTES_PER_ELEMENT"in o&&S(o)>u&&I.clockSequence&&"BYTES_PER_ELEMENT"in I.clockSequence&&(I.clockSequence[1]+=1);for(var d=u.toString(2).padStart(60,"0"),f=[],p=60;p>0;p-=8){var m=d.slice(p-8,p).padStart(8,"0");f.unshift(parseInt(m,2))}n=new Uint8Array(f)}else if(/^[35]$/.test(e.toString())){var h=c(e,t,r),_="";_=h.slice(0,8),_=h.slice(8,12)+_,_=h.slice(12,16)+_;var v=parseInt(_,16).toString(2).padStart(60,"0");n=i(v)}else(n=l(8))[7]=parseInt(n[7].toString(2).slice(0,4),2);return I.timestamp=n,n}var y=function(e){void 0===e&&(e={}),this.version="4",this.clockSequenceGetter=h,this.nodeIdentifierGetter=v,this.timestampGetter=g;var t=e||{};if(t.version){if(!s(t.version))throw new Error(a.UUID_VERSION_INVALID);this.version=t.version}if("function"==typeof t.clockSequenceGetter&&(this.clockSequenceGetter=t.clockSequenceGetter),"function"==typeof t.nodeIdentifierGetter&&(this.nodeIdentifierGetter=t.nodeIdentifierGetter),"function"==typeof t.timestampGetter&&(this.timestampGetter=t.timestampGetter),t.name&&"string"==typeof t.name&&(this.name=t.name),t.namespaceId&&"string"==typeof t.namespaceId&&(this.namespaceId=t.namespaceId),/^[35]$/.test(this.version.toString())){if(!this.namespaceId)throw new Error(a.NAMESPACE_ID_MISSING);if(!this.name)throw new Error(a.NAME_MISSING)}},A=function(e){var t=e.toString(2).split("").reverse().join("");return parseInt(t,2).toString(16)},b=function(e){if(!d(e))throw new Error(a.UUID_LAST_RESULTS_INVALID);var t={clockSequence:Array.from(e.clockSequence),nodeIdentifier:Array.from(e.nodeIdentifier),timestamp:Array.from(e.timestamp)};try{Object(u.writeFileSync)(Object(p.join)(Object(f.homedir)(),"ifid"),JSON.stringify(t),{encoding:"utf8"})}catch(e){console.error("Could not save results.")}};function N(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var U=function(){function e(e){var t=new y;"object"==typeof e&&e&&(e.version&&(t.version=e.version),e.clockSequenceGetter&&(t.clockSequenceGetter=e.clockSequenceGetter),e.timestampGetter&&(t.timestampGetter=e.timestampGetter),e.nodeIdentifierGetter&&(t.nodeIdentifierGetter=e.nodeIdentifierGetter),e.namespaceId&&(t.namespaceId=e.namespaceId),e.name&&(t.name=e.name));var r=t.version;if(!s(r))throw new Error(a.UUID_VERSION_INVALID);if(m()||"1"===r.toString()&&(console.error("The time-based version 1 UUID cannot be created within the browser. Falling back to the pseudo-random version 4."),r="4"),this.__version=r,/^[35]$/.test(r.toString())){var n=t.clockSequenceGetter(r,t.namespaceId,t.name);this.__clockSequence=n;var i=t.timestampGetter(r,t.namespaceId,t.name);this.__timestamp=i;var o=t.nodeIdentifierGetter(r,t.namespaceId,t.name);this.__nodeIdentifier=o}else{var c=t.clockSequenceGetter(r);this.__clockSequence=c;var u=t.timestampGetter(r);this.__timestamp=u;var d=t.nodeIdentifierGetter(r);this.__nodeIdentifier=d,m()&&"1"===this.version.toString()&&b(this)}}return e.parse=function(e){var t=e.split("-");if(5!==t.length)throw new Error(a.UUID_STRING_INVALID);for(var r=function(e){return parseInt(parseInt(e,16).toString(2).split("").reverse().join(),2).toString(16)},n=r(t[0]),i=r(t[1]),o=r(t[2]),c=o.slice(0,3),s=o[4],u=c+i+n,d=[],f=0;f<16;f+=2)d.push(parseInt(u.slice(f,f+2),16));for(var p=new Uint8Array(d),I=r(t[3]),m=I.slice(0,2),l=parseInt(parseInt(m,16).toString(2).slice(2),2).toString(16),S=I.slice(2,4)+l,h=[],_=0;_<7;_+=2)h.push(parseInt(S.slice(_,_+2),16));for(var v=new Uint8Array(h),E=r(t[4]),g=[],y=0;y<12;y+=2)g.push(parseInt(E.slice(y,y+2),16));var A=new Uint8Array(g);return Object.assign({},this.prototype,{__version:s,__timestamp:p,__clockSequence:v,__nodeIdentifier:A})},e.prototype.toString=function(){var e=function(e,t){return A(S(e)).padEnd(t,"0")};return e(this.timeLow,8)+"-"+e(this.timeMid,4)+"-"+e(this.timeHighAndVersion,4)+"-"+e(this.clockSequenceHighAndReserved,2)+e(this.clockSequenceLow,2)+"-"+e(this.nodeIdentifier,12)},function(e,t,r){t&&N(e.prototype,t),r&&N(e,r)}(e,[{key:"version",get:function(){return this.__version}},{key:"timestamp",get:function(){return this.__timestamp}},{key:"timeLow",get:function(){return this.timestamp.slice(4,8)}},{key:"timeMid",get:function(){return this.timestamp.slice(2,4)}},{key:"timeHigh",get:function(){return this.timestamp.slice(0,2)}},{key:"timeHighAndVersion",get:function(){var e=this.timeHigh,t=parseInt(this.version.toString()).toString(2),r=S(e).toString(2),n=t.padStart(4,"0")+r.padStart(12,"0"),i=parseInt(n.slice(0,8),2),o=parseInt(n.slice(8,16),2);return new Uint8Array([i,o])}},{key:"clockSequence",get:function(){return this.__clockSequence}},{key:"clockSequenceLow",get:function(){return this.clockSequence.slice(0,1)}},{key:"clockSequenceHigh",get:function(){return this.clockSequence.slice(1)}},{key:"reserved",get:function(){return new Uint8Array([2])}},{key:"clockSequenceHighAndReserved",get:function(){var e=S(this.clockSequenceHigh).toString(2),t=S(this.reserved).toString(2),r=e.padStart(6,"0")+t.padStart(2,"0");return new Uint8Array([parseInt(r,2)])}},{key:"nodeIdentifier",get:function(){return this.__nodeIdentifier}}]),e}();r.d(t,"NamespaceIds",function(){return n}),r.d(t,"UUIDOptions",function(){return y}),r.d(t,"UUID",function(){return U}),r.d(t,"clockSequenceGetter",function(){return h}),r.d(t,"getHashFromNamespaceIdAndName",function(){return c}),r.d(t,"getHundredsOfNanosecondsSinceGregorianReform",function(){return E}),r.d(t,"nodeIdentifierGetter",function(){return v}),r.d(t,"numberAsLittleEndianHexStr",function(){return A}),r.d(t,"timestampGetter",function(){return g}),r.d(t,"uintArrayAsNumber",function(){return S})}])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.ifid=t():e.ifid=t()}(this,function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=4)}([function(e,t){e.exports=require("os")},function(e,t){e.exports=require("crypto")},function(e,t){e.exports=require("fs")},function(e,t){e.exports=require("path")},function(e,t,r){"use strict";var n;r.r(t),function(e){e.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",e.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",e.OID="6ba7b812-9dad-11d1-80b4-00c04fd430c8",e.X500="6ba7b814-9dad-11d1-80b4-00c04fd430c8"}(n||(n={}));var i=function(e){for(var t=[],r=e.length;r>0;r-=8){var n=e.slice(r-8,r).padStart(8,"0");t.unshift(parseInt(n,2))}return new Uint8Array(t)},o=r(1),a={BIT_ARRAY_INVALID:"The array of bits was not an array, had no contents, or had one or more items which did not meet the isBit type guard.",UUID_VERSION_INVALID:"The version argument was not a valid UUID version.",TIMESTAMP_GENERATION_FAILED:"The random number generator did not produce an acceptable value for the random number used in place of a stable timestamp.",TIMESTAMP_INVALID:"The timestamp property of the UUID object is malformed.",NAMESPACE_ID_MISSING:"In order to construct a v3 or v5 UUID, you need to provide a namespace ID to be hashed.",NAME_MISSING:"In order to construct a v3 or v5 UUID, you need to provide a name to be hashed.",CLOCK_SEQUENCE_INVALID:"The clockSequence property of the UUID object is malformed.",CLOCK_SEQUENCE_GENERATION_FAILED:"The random number generator did not produce an acceptable value for the random number used in place of a stable clock sequence.",CLOCK_SEQUENCE_LOW_INVALID:"The clockSequenceLow property of the UUID object is malformed.",CLOCK_SEQUENCE_HIGH_INVALID:"The clockSequenceHigh property of the UUID object is malformed.",CLOCK_HIGH_AND_RESERVED_INVALID:"The clockSequenceHighAndReserved property of the UUID object is malformed.",MAC_ADDRESS_UNAVAILABLE:"The MAC address is unavailable, which makes creating the version 1 node ID impossible.",MAC_ADDRESS_INVALID:"The MAC address was found, but it was malformed.",UUID_LAST_RESULTS_INVALID:"The provided last results object did not meet the isValidLastResults type guard.",UUID_STRING_INVALID:"The text argument passed to UUID.parse was malformed.",UUID_OPTIONS_INVALID:"The options argument passed to one of the UUID methods did not meet the isUUIDOptions type guard.",TIME_LOW_INVALID:"The timestamp property did not produce a valid low portion of the timestamp.",TIME_MID_INVALID:"The timestamp property did not produce a valid mid portion of the timestamp.",TIME_HIGH_INVALID:"The timestamp property did not produce a valid high portion of the timestamp.",TIME_HIGH_AND_VERSION_INVALID:"The timestamp property did not produce a valid high-and-version multiplex.",NODE_IDENTIFIER_INVALID:"The nodeIdentifier property of the UUID object was malformed."},c=function(e,t,r){if(!t)throw new Error(a.NAMESPACE_ID_MISSING);if(!r)throw new Error(a.NAME_MISSING);var n;n="3"===e.toString()?Object(o.createHash)("md5"):Object(o.createHash)("sha1");var i=t.split("-").map(function(e){var t=e.length;return parseInt(parseInt(e,16).toString(2).split("").reverse().join(""),2).toString(16).padEnd(t,"0")}).join("-");return n.update(i+r),n.digest("hex")};function s(e){return/^[1345]$/.test(e.toString())}var u=r(2);function d(e){return"object"==typeof e&&e&&e.clockSequence&&"BYTES_PER_ELEMENT"in e.clockSequence&&e.nodeIdentifier&&"BYTES_PER_ELEMENT"in e.nodeIdentifier&&e.timestamp&&"BYTES_PER_ELEMENT"in e.timestamp}var f=r(0),p=r(3),I=function(){var e=null;try{var t=Object(u.readFileSync)(Object(p.join)(Object(f.homedir)(),"ifid"),"utf8");e=JSON.parse(t)}catch(e){}return d(e)?e:{}}(),m=function(){return Boolean("undefined"!=typeof process&&process.versions&&process.versions.node)},l=function(e){if(m())return new Uint8Array(Object(o.randomBytes)(e));for(var t=t||msCrypto,r=new Uint8Array(e),n=0;n<e;n+=65536)t.getRandomValues(r.subarray(n,n+Math.min(e-n,65536)));return r},S=function(e){return parseInt(Buffer.from(e).toString("hex"),16)};function h(e,t,r){if(!s(e))throw new Error(a.UUID_VERSION_INVALID);var n;if(/^[14]$/.test(e.toString())){if(I.clockSequence&&"BYTES_PER_ELEMENT"in I.clockSequence)return I.clockSequence;n=function(){var e=S(l(2)).toString(2).slice(0,14);return new Uint8Array([parseInt(e.slice(0,6),2),parseInt(e.slice(6),2)])}(),"1"===e.toString()&&(I.clockSequence=n)}else{var o=c(e,t,r),u="";u+=o.slice(16,18),u+=o.slice(18,20);var d=parseInt(u,16).toString(2).padStart(14,"0");n=i(d)}return n}function _(){for(var e=Object(f.networkInterfaces)(),t=Object.keys(e),r=0;r<t.length;r+=1)for(var n=e[t[r]],i=0;i<n.length;i+=1){var o=n[i];if("object"==typeof o&&o){var c=o.mac;if("string"==typeof c&&c&&"00:00:00:00:00:00"!==c){var s=c.split(":").map(function(e){return parseInt(e,16)});return new Uint8Array(s)}}}throw new Error(a.MAC_ADDRESS_UNAVAILABLE)}function v(e,t,r){var n;if("1"===e.toString()){if(I.nodeIdentifier&&"BYTES_PER_ELEMENT"in I.nodeIdentifier)return I.nodeIdentifier;n=_(),I.nodeIdentifier=n}else if(/^[35]$/.test(e.toString())){var o="";o+=c(e,t,r).slice(20,32);var s=parseInt(o,16).toString(2).padStart(48,"0");n=i(s)}else{if("4"!==e.toString())throw new Error(a.UUID_VERSION_INVALID);n=l(6)}return n}function E(){return 10*((new Date).getTime()-new Date(1582,9,15).getTime())}function g(e,t,r){if(!s(e))throw new Error(a.UUID_VERSION_INVALID);var n;if("1"===e.toString()){var o=I.timestamp,u=E();o&&"BYTES_PER_ELEMENT"in o&&S(o)>u&&I.clockSequence&&"BYTES_PER_ELEMENT"in I.clockSequence&&(I.clockSequence[1]+=1);for(var d=u.toString(2).padStart(60,"0"),f=[],p=60;p>0;p-=8){var m=d.slice(p-8,p).padStart(8,"0");f.unshift(parseInt(m,2))}n=new Uint8Array(f)}else if(/^[35]$/.test(e.toString())){var h=c(e,t,r),_="";_=h.slice(0,8),_=h.slice(8,12)+_,_=h.slice(12,16)+_;var v=parseInt(_,16).toString(2).padStart(60,"0");n=i(v)}else(n=l(8))[7]=parseInt(n[7].toString(2).slice(0,4),2);return I.timestamp=n,n}var y=function(e){void 0===e&&(e={}),this.version="4",this.clockSequenceGetter=h,this.nodeIdentifierGetter=v,this.timestampGetter=g;var t=e||{};if(t.version){if(!s(t.version))throw new Error(a.UUID_VERSION_INVALID);this.version=t.version}if("function"==typeof t.clockSequenceGetter&&(this.clockSequenceGetter=t.clockSequenceGetter),"function"==typeof t.nodeIdentifierGetter&&(this.nodeIdentifierGetter=t.nodeIdentifierGetter),"function"==typeof t.timestampGetter&&(this.timestampGetter=t.timestampGetter),t.name&&"string"==typeof t.name&&(this.name=t.name),t.namespaceId&&"string"==typeof t.namespaceId&&(this.namespaceId=t.namespaceId),/^[35]$/.test(this.version.toString())){if(!this.namespaceId)throw new Error(a.NAMESPACE_ID_MISSING);if(!this.name)throw new Error(a.NAME_MISSING)}},A=function(e){var t=e.toString(2).split("").reverse().join("");return parseInt(t,2).toString(16)},b=function(e){if(!d(e))throw new Error(a.UUID_LAST_RESULTS_INVALID);var t={clockSequence:Array.from(e.clockSequence),nodeIdentifier:Array.from(e.nodeIdentifier),timestamp:Array.from(e.timestamp)};try{Object(u.writeFileSync)(Object(p.join)(Object(f.homedir)(),"ifid"),JSON.stringify(t),{encoding:"utf8"})}catch(e){console.error("Could not save results.")}};function N(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var U=function(){function e(e){var t=new y;"object"==typeof e&&e&&(e.version&&(t.version=e.version),e.clockSequenceGetter&&(t.clockSequenceGetter=e.clockSequenceGetter),e.timestampGetter&&(t.timestampGetter=e.timestampGetter),e.nodeIdentifierGetter&&(t.nodeIdentifierGetter=e.nodeIdentifierGetter),e.namespaceId&&(t.namespaceId=e.namespaceId),e.name&&(t.name=e.name));var r=t.version;if(!s(r))throw new Error(a.UUID_VERSION_INVALID);if(m()||"1"===r.toString()&&(console.error("The time-based version 1 UUID cannot be created within the browser. Falling back to the pseudo-random version 4."),r="4"),this.__version=r,/^[35]$/.test(r.toString())){var n=t.clockSequenceGetter(r,t.namespaceId,t.name);this.__clockSequence=n;var i=t.timestampGetter(r,t.namespaceId,t.name);this.__timestamp=i;var o=t.nodeIdentifierGetter(r,t.namespaceId,t.name);this.__nodeIdentifier=o}else{var c=t.clockSequenceGetter(r);this.__clockSequence=c;var u=t.timestampGetter(r);this.__timestamp=u;var d=t.nodeIdentifierGetter(r);this.__nodeIdentifier=d,m()&&"1"===this.version.toString()&&b(this)}}return e.parse=function(e){var t=e.split("-");if(5!==t.length)throw new Error(a.UUID_STRING_INVALID);for(var r=function(e){return parseInt(parseInt(e,16).toString(2).split("").reverse().join(),2).toString(16)},n=r(t[0]),i=r(t[1]),o=r(t[2]),c=o.slice(0,3),s=o[4],u=c+i+n,d=[],f=0;f<16;f+=2)d.push(parseInt(u.slice(f,f+2),16));for(var p=new Uint8Array(d),I=r(t[3]),m=I.slice(0,2),l=parseInt(parseInt(m,16).toString(2).slice(2),2).toString(16),S=I.slice(2,4)+l,h=[],_=0;_<7;_+=2)h.push(parseInt(S.slice(_,_+2),16));for(var v=new Uint8Array(h),E=r(t[4]),g=[],y=0;y<12;y+=2)g.push(parseInt(E.slice(y,y+2),16));var A=new Uint8Array(g);return Object.assign({},this.prototype,{__version:s,__timestamp:p,__clockSequence:v,__nodeIdentifier:A})},e.prototype.toString=function(){var e=function(e,t){return A(S(e)).padEnd(t,"0")};return e(this.timeLow,8)+"-"+e(this.timeMid,4)+"-"+e(this.timeHighAndVersion,4)+"-"+e(this.clockSequenceHighAndReserved,2)+e(this.clockSequenceLow,2)+"-"+e(this.nodeIdentifier,12)},function(e,t,r){t&&N(e.prototype,t),r&&N(e,r)}(e,[{key:"version",get:function(){return this.__version}},{key:"timestamp",get:function(){return this.__timestamp}},{key:"timeLow",get:function(){return this.timestamp.slice(4,8)}},{key:"timeMid",get:function(){return this.timestamp.slice(2,4)}},{key:"timeHigh",get:function(){return this.timestamp.slice(0,2)}},{key:"timeHighAndVersion",get:function(){var e=this.timeHigh,t=parseInt(this.version.toString()).toString(2),r=S(e).toString(2),n=t.padStart(4,"0")+r.padStart(12,"0"),i=parseInt(n.slice(0,8),2),o=parseInt(n.slice(8,16),2);return new Uint8Array([i,o])}},{key:"clockSequence",get:function(){return this.__clockSequence}},{key:"clockSequenceLow",get:function(){return this.clockSequence.slice(0,1)}},{key:"clockSequenceHigh",get:function(){return this.clockSequence.slice(1)}},{key:"reserved",get:function(){return new Uint8Array([2])}},{key:"clockSequenceHighAndReserved",get:function(){var e=S(this.clockSequenceHigh).toString(2),t=S(this.reserved).toString(2),r=e.padStart(6,"0")+t.padStart(2,"0");return new Uint8Array([parseInt(r,2)])}},{key:"nodeIdentifier",get:function(){return this.__nodeIdentifier}}]),e}();r.d(t,"NamespaceIds",function(){return n}),r.d(t,"UUIDOptions",function(){return y}),r.d(t,"UUID",function(){return U}),r.d(t,"clockSequenceGetter",function(){return h}),r.d(t,"getHashFromNamespaceIdAndName",function(){return c}),r.d(t,"getHundredsOfNanosecondsSinceGregorianReform",function(){return E}),r.d(t,"nodeIdentifierGetter",function(){return v}),r.d(t,"numberAsLittleEndianHexStr",function(){return A}),r.d(t,"timestampGetter",function(){return g}),r.d(t,"uintArrayAsNumber",function(){return S})}])}); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "big-uuid", | ||
"version": "0.1.7", | ||
"version": "0.1.8", | ||
"description": "An RFC 4112 conformant UUID generator creating v1, v3, v4, and v5 UUIDs.", | ||
@@ -5,0 +5,0 @@ "main": "dist/umd/index.js", |
@@ -41,2 +41,3 @@ const path = require('path'); | ||
libraryTarget: 'umd', | ||
globalObject: 'this', | ||
}, | ||
@@ -43,0 +44,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
126073
1899