diff --git a/dist/short-unique-id.js b/dist/short-unique-id.js index cad4805..1b2a0a6 100644 --- a/dist/short-unique-id.js +++ b/dist/short-unique-id.js @@ -69,7 +69,7 @@ return to; } - var version = "4.3.0"; + var version = "4.3.1"; // @module ShortUniqueId /** diff --git a/dist/short-unique-id.min.js b/dist/short-unique-id.min.js index baeeaed..9d99a76 100644 --- a/dist/short-unique-id.min.js +++ b/dist/short-unique-id.min.js @@ -1 +1 @@ -(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?module.exports=factory():typeof define==="function"&&define.amd?define(factory):(global=typeof globalThis!=="undefined"?globalThis:global||self,global.ShortUniqueId=factory())})(this,(function(){"use strict";var extendStatics=function(d,b){extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)if(Object.prototype.hasOwnProperty.call(b,p))d[p]=b[p]};return extendStatics(d,b)};function __extends(d,b){if(typeof b!=="function"&&b!==null)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");extendStatics(d,b);function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)}var __assign=function(){__assign=Object.assign||function __assign(t){for(var s,i=1,n=arguments.length;i0)&&!(r=i.next()).done)ar.push(r.value)}catch(error){e={error:error}}finally{try{if(r&&!r.done&&(m=i["return"]))m.call(i)}finally{if(e)throw e.error}}return ar}function __spreadArray(to,from){for(var i=0,il=from.length,j=to.length;i1){finalDict=dictionary}else{finalDict=[];var i_1;_this.dictIndex=i_1=0;var rangesName="_"+dictionary+"_dict_ranges";var ranges_1=_this[rangesName];Object.keys(ranges_1).forEach((function(rangeType){var rangeTypeKey=rangeType;_this.dictRange=ranges_1[rangeTypeKey];_this.lowerBound=_this.dictRange[0];_this.upperBound=_this.dictRange[1];for(_this.dictIndex=i_1=_this.lowerBound;_this.lowerBound<=_this.upperBound?i_1<_this.upperBound:i_1>_this.upperBound;_this.dictIndex=_this.lowerBound<=_this.upperBound?i_1+=1:i_1-=1){finalDict.push(String.fromCharCode(_this.dictIndex))}}))}if(shuffle){var PROBABILITY_1=.5;finalDict=finalDict.sort((function(){return Math.random()-PROBABILITY_1}))}_this.dict=finalDict;_this.dictLength=_this.dict.length;_this.counter=0};_this.seq=function(){return _this.sequentialUUID()};_this.sequentialUUID=function(){var counterDiv;var counterRem;var id="";counterDiv=_this.counter;do{counterRem=counterDiv%_this.dictLength;counterDiv=Math.trunc(counterDiv/_this.dictLength);id+=_this.dict[counterRem]}while(counterDiv!==0);_this.counter+=1;return id};_this.randomUUID=function(uuidLength){if(uuidLength===void 0){uuidLength=_this.uuidLength||DEFAULT_UUID_LENGTH}var id;var randomPartIdx;var j;if(uuidLength===null||typeof uuidLength==="undefined"||uuidLength<1){throw new Error("Invalid UUID Length Provided")}id="";for(j=0;j1?1:score<0?0:score};_this.getVersion=function(){return _this.version};_this.stamp=function(finalLength){if(typeof finalLength!=="number"||finalLength<10){throw new Error("Param finalLength must be number greater than 10")}var hexStamp=Math.floor(+new Date/1e3).toString(16);var idLength=finalLength-9;var rndIdx=Math.round(Math.random()*(idLength>15?15:idLength));var id=_this.randomUUID(idLength);return""+id.substr(0,rndIdx)+hexStamp+id.substr(rndIdx)+rndIdx.toString(16)};_this.parseStamp=function(stamp){if(stamp.length<10){throw new Error("Stamp length invalid")}var rndIdx=parseInt(stamp.substr(stamp.length-1,1),16);return new Date(parseInt(stamp.substr(rndIdx,8),16)*1e3)};var options=__assign(__assign({},DEFAULT_OPTIONS),argOptions);_this.counter=0;_this.debug=false;_this.dict=[];_this.version=version;var dictionary=options.dictionary,shuffle=options.shuffle,length=options.length;_this.uuidLength=length;_this.setDictionary(dictionary,shuffle);_this.debug=options.debug;_this.log(_this.dict);_this.log("Generator instantiated with Dictionary Size "+_this.dictLength);return new Proxy(_this,{apply:function(target,that,args){return _this.randomUUID.apply(_this,__spreadArray([],__read(args)))}})}return ShortUniqueId}(Function);return ShortUniqueId})); \ No newline at end of file +(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?module.exports=factory():typeof define==="function"&&define.amd?define(factory):(global=typeof globalThis!=="undefined"?globalThis:global||self,global.ShortUniqueId=factory())})(this,(function(){"use strict";var extendStatics=function(d,b){extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)if(Object.prototype.hasOwnProperty.call(b,p))d[p]=b[p]};return extendStatics(d,b)};function __extends(d,b){if(typeof b!=="function"&&b!==null)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");extendStatics(d,b);function __(){this.constructor=d}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __)}var __assign=function(){__assign=Object.assign||function __assign(t){for(var s,i=1,n=arguments.length;i0)&&!(r=i.next()).done)ar.push(r.value)}catch(error){e={error:error}}finally{try{if(r&&!r.done&&(m=i["return"]))m.call(i)}finally{if(e)throw e.error}}return ar}function __spreadArray(to,from){for(var i=0,il=from.length,j=to.length;i1){finalDict=dictionary}else{finalDict=[];var i_1;_this.dictIndex=i_1=0;var rangesName="_"+dictionary+"_dict_ranges";var ranges_1=_this[rangesName];Object.keys(ranges_1).forEach((function(rangeType){var rangeTypeKey=rangeType;_this.dictRange=ranges_1[rangeTypeKey];_this.lowerBound=_this.dictRange[0];_this.upperBound=_this.dictRange[1];for(_this.dictIndex=i_1=_this.lowerBound;_this.lowerBound<=_this.upperBound?i_1<_this.upperBound:i_1>_this.upperBound;_this.dictIndex=_this.lowerBound<=_this.upperBound?i_1+=1:i_1-=1){finalDict.push(String.fromCharCode(_this.dictIndex))}}))}if(shuffle){var PROBABILITY_1=.5;finalDict=finalDict.sort((function(){return Math.random()-PROBABILITY_1}))}_this.dict=finalDict;_this.dictLength=_this.dict.length;_this.counter=0};_this.seq=function(){return _this.sequentialUUID()};_this.sequentialUUID=function(){var counterDiv;var counterRem;var id="";counterDiv=_this.counter;do{counterRem=counterDiv%_this.dictLength;counterDiv=Math.trunc(counterDiv/_this.dictLength);id+=_this.dict[counterRem]}while(counterDiv!==0);_this.counter+=1;return id};_this.randomUUID=function(uuidLength){if(uuidLength===void 0){uuidLength=_this.uuidLength||DEFAULT_UUID_LENGTH}var id;var randomPartIdx;var j;if(uuidLength===null||typeof uuidLength==="undefined"||uuidLength<1){throw new Error("Invalid UUID Length Provided")}id="";for(j=0;j1?1:score<0?0:score};_this.getVersion=function(){return _this.version};_this.stamp=function(finalLength){if(typeof finalLength!=="number"||finalLength<10){throw new Error("Param finalLength must be number greater than 10")}var hexStamp=Math.floor(+new Date/1e3).toString(16);var idLength=finalLength-9;var rndIdx=Math.round(Math.random()*(idLength>15?15:idLength));var id=_this.randomUUID(idLength);return""+id.substr(0,rndIdx)+hexStamp+id.substr(rndIdx)+rndIdx.toString(16)};_this.parseStamp=function(stamp){if(stamp.length<10){throw new Error("Stamp length invalid")}var rndIdx=parseInt(stamp.substr(stamp.length-1,1),16);return new Date(parseInt(stamp.substr(rndIdx,8),16)*1e3)};var options=__assign(__assign({},DEFAULT_OPTIONS),argOptions);_this.counter=0;_this.debug=false;_this.dict=[];_this.version=version;var dictionary=options.dictionary,shuffle=options.shuffle,length=options.length;_this.uuidLength=length;_this.setDictionary(dictionary,shuffle);_this.debug=options.debug;_this.log(_this.dict);_this.log("Generator instantiated with Dictionary Size "+_this.dictLength);return new Proxy(_this,{apply:function(target,that,args){return _this.randomUUID.apply(_this,__spreadArray([],__read(args)))}})}return ShortUniqueId}(Function);return ShortUniqueId})); \ No newline at end of file diff --git a/docs/classes/default.html b/docs/classes/default.html index 015cd51..75abe09 100644 --- a/docs/classes/default.html +++ b/docs/classes/default.html @@ -4,7 +4,7 @@ Short Unique ID - Short UUID Generator - + @@ -293,7 +293,7 @@

constructor

Parameters

@@ -315,7 +315,7 @@

counter

counter: number
@@ -325,7 +325,7 @@

debug

debug: boolean
@@ -335,7 +335,7 @@

dict

dict: string[]
@@ -345,7 +345,7 @@

dictIndex

dictIndex: number = 0
@@ -355,7 +355,7 @@

dictLength

dictLength: number = 0
@@ -365,7 +365,7 @@

dictRange

dictRange: number[] = []
@@ -375,7 +375,7 @@

lowerBound

lowerBound: number = 0
@@ -385,7 +385,7 @@

upperBound

upperBound: number = 0
@@ -395,7 +395,7 @@

uuidLength

uuidLength: number
@@ -405,7 +405,7 @@

version

version: string
@@ -422,7 +422,7 @@

approxMaxBeforeCollision

  • @@ -461,7 +461,7 @@

    availableUUIDs

  • @@ -498,7 +498,7 @@

    collisionProbability

  • @@ -543,7 +543,7 @@

    getVersion

  • @@ -565,7 +565,7 @@

    parseStamp

  • @@ -600,7 +600,7 @@

    randomUUID

  • @@ -633,7 +633,7 @@

    seq

  • Returns string

    @@ -650,7 +650,7 @@

    sequentialUUID

  • @@ -677,7 +677,7 @@

    setDictionary

  • @@ -708,7 +708,7 @@

    stamp

  • @@ -743,7 +743,7 @@

    uniqueness

  • diff --git a/docs/index.html b/docs/index.html index 244865c..64de06c 100644 --- a/docs/index.html +++ b/docs/index.html @@ -4,7 +4,7 @@ Short Unique ID - Short UUID Generator - + @@ -15,7 +15,7 @@
    -

    short-unique-id - v4.3.0

    +

    short-unique-id - v4.3.1

    diff --git a/docs/interfaces/shortuniqueidoptions.html b/docs/interfaces/shortuniqueidoptions.html index 2e06113..4eed81f 100644 --- a/docs/interfaces/shortuniqueidoptions.html +++ b/docs/interfaces/shortuniqueidoptions.html @@ -4,7 +4,7 @@ Short Unique ID - Short UUID Generator - + @@ -123,7 +123,7 @@

    debug

    debug: boolean
    @@ -138,7 +138,7 @@

    dictionary

    dictionary: string[] | defaultDictionaries
    @@ -153,7 +153,7 @@

    length

    length: number
    @@ -168,7 +168,7 @@

    shuffle

    shuffle: boolean
    diff --git a/docs/modules.html b/docs/modules.html index d4d2467..a680299 100644 --- a/docs/modules.html +++ b/docs/modules.html @@ -4,7 +4,7 @@ Short Unique ID - Short UUID Generator - + @@ -15,7 +15,7 @@
    -

    short-unique-id - v4.3.0

    +

    short-unique-id - v4.3.1

    @@ -77,7 +77,7 @@

    Const DEFAULT_UUID_LENG
    DEFAULT_UUID_LENGTH: number = 6