diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..e9143e4 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,10 @@ +# Changelog + +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. + +## [3.2.0](https://github.com/jeanlescure/short-unique-id/compare/v3.0.5...v3.2.0) (2020-11-05) + + +### Features + +* implement cli ([9555cb9](https://github.com/jeanlescure/short-unique-id/commit/9555cb9b1de9d521ad2a7760be963fc178b62d63)) diff --git a/dist/short-unique-id.js b/dist/short-unique-id.js index 25a3249..f99ccc1 100644 --- a/dist/short-unique-id.js +++ b/dist/short-unique-id.js @@ -106,7 +106,7 @@ System.register("version", [], function (exports_1, context_1) { return { setters: [], execute: function () { - exports_1("default", '3.1.5'); + exports_1("default", '3.2.0'); } }; }); diff --git a/dist/short-unique-id.min.js b/dist/short-unique-id.min.js index 1da29ff..b07ed1c 100644 --- a/dist/short-unique-id.min.js +++ b/dist/short-unique-id.min.js @@ -1 +1 @@ -var __suid_module=function t(e,i,n){function s(o,u){if(!i[o]){if(!e[o]){var h="function"==typeof require&&require;if(!u&&h)return h(o,!0);if(r)return r(o,!0);var d=new Error("Cannot find module '"+o+"'");throw d.code="MODULE_NOT_FOUND",d}var a=i[o]={exports:{}};e[o][0].call(a.exports,(function(t){return s(e[o][1][t]||t)}),a,a.exports,t,e,i,n)}return i[o].exports}for(var r="function"==typeof require&&require,o=0;o{const e=new Map;function i(i,n){return{id:i,import:n=>async function(i,n){let s=i.replace(/\.\w+$/i,"");if(s.includes("./")){const[t,...e]=s.split("/").reverse(),[,...i]=n.split("/").reverse(),r=[t];let o,u=0;for(;o=e.shift();)if(".."===o)u++;else{if("."===o)break;r.push(o)}ut(i))}(n,i),meta:{url:i,main:n}}}function r(t){return(e,i)=>{i="string"==typeof e?{[e]:i}:e;for(const[e,n]of Object.entries(i))Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0})}}async function o(t){if(!e.has(t))return;const i=e.get(t);if(i.s){const{d:t,e:e,s:n}=i;delete i.s,delete i.e;for(let e=0;e(n=s=void 0,function(t){for(const[n,s]of e.entries()){const{f:e,exp:o}=s,{execute:u,setters:h}=e(r(o),i(n,n===t));delete s.f,s.e=u,s.s=h}}(t),u?o(t):function t(i){if(!e.has(i))return;const n=e.get(i);if(n.s){const{d:e,e:i,s:s}=n;delete n.s,delete n.e;for(let i=0;i1)this.setDictionary(r);else{let t;this.dictIndex=t=0,Object.keys(n).forEach(e=>{const i=e;for(this.dictRange=n[i],this.lowerBound=this.dictRange[0],this.upperBound=this.dictRange[1],this.dictIndex=t=this.lowerBound;this.lowerBound<=this.upperBound?tthis.upperBound;this.dictIndex=this.lowerBound<=this.upperBound?t+=1:t-=1)this.dict.push(String.fromCharCode(this.dictIndex))})}if(o){const t=.5;this.setDictionary(this.dict.sort(()=>Math.random()-t))}else this.setDictionary(this.dict);return this.debug=e.debug,this.log(this.dict),this.log("Generator instantiated with Dictionary Size "+this.dictLength),new Proxy(this,{apply:(t,e,i)=>this.randomUUID(...i)})}log(...t){const e=[...t];if(e[0]="[short-unique-id] "+t[0],!0===this.debug&&"undefined"!=typeof console&&null!==console)return console.log(...e)}setDictionary(t){this.dict=t,this.dictLength=this.dict.length,this.counter=0}seq(){return this.sequentialUUID()}sequentialUUID(){let t,e,i="";for(t=this.counter;e=t%this.dictLength,t=Math.trunc(t/this.dictLength),i+=this.dict[e],0!==t;);return this.counter+=1,i}randomUUID(t=this.uuidLength||6){let e,i,n,s;if(null==t||t<1)throw new Error("Invalid UUID Length Provided");for(e="",s=n=0;0<=t?nt;s=0<=t?n+=1:n-=1)i=parseInt((Math.random()*this.dictLength).toFixed(0),10)%this.dictLength,e+=this.dict[i];return e}availableUUIDs(t=this.uuidLength){return parseFloat(Math.pow([...new Set(this.dict)].length,t).toFixed(0))}approxMaxBeforeCollision(t=this.availableUUIDs(this.uuidLength)){return parseFloat(Math.sqrt(Math.PI/2*t).toFixed(20))}collisionProbability(t=this.availableUUIDs(this.uuidLength),e=this.uuidLength){return parseFloat((this.approxMaxBeforeCollision(t)/this.availableUUIDs(e)).toFixed(20))}uniqueness(t=this.availableUUIDs(this.uuidLength)){const e=parseFloat((1-this.approxMaxBeforeCollision(t)/t).toFixed(20));return e>1?1:e<0?0:e}getVersion(){return this.version}})}}}));const r=s("mod",!1);i.default=r.default},{}]},{},[1]),ShortUniqueId=__suid_module(1).default; +var __suid_module=function t(e,i,n){function s(o,u){if(!i[o]){if(!e[o]){var h="function"==typeof require&&require;if(!u&&h)return h(o,!0);if(r)return r(o,!0);var d=new Error("Cannot find module '"+o+"'");throw d.code="MODULE_NOT_FOUND",d}var a=i[o]={exports:{}};e[o][0].call(a.exports,(function(t){return s(e[o][1][t]||t)}),a,a.exports,t,e,i,n)}return i[o].exports}for(var r="function"==typeof require&&require,o=0;o{const e=new Map;function i(i,n){return{id:i,import:n=>async function(i,n){let s=i.replace(/\.\w+$/i,"");if(s.includes("./")){const[t,...e]=s.split("/").reverse(),[,...i]=n.split("/").reverse(),r=[t];let o,u=0;for(;o=e.shift();)if(".."===o)u++;else{if("."===o)break;r.push(o)}ut(i))}(n,i),meta:{url:i,main:n}}}function r(t){return(e,i)=>{i="string"==typeof e?{[e]:i}:e;for(const[e,n]of Object.entries(i))Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0})}}async function o(t){if(!e.has(t))return;const i=e.get(t);if(i.s){const{d:t,e:e,s:n}=i;delete i.s,delete i.e;for(let e=0;e(n=s=void 0,function(t){for(const[n,s]of e.entries()){const{f:e,exp:o}=s,{execute:u,setters:h}=e(r(o),i(n,n===t));delete s.f,s.e=u,s.s=h}}(t),u?o(t):function t(i){if(!e.has(i))return;const n=e.get(i);if(n.s){const{d:e,e:i,s:s}=n;delete n.s,delete n.e;for(let i=0;i1)this.setDictionary(r);else{let t;this.dictIndex=t=0,Object.keys(n).forEach(e=>{const i=e;for(this.dictRange=n[i],this.lowerBound=this.dictRange[0],this.upperBound=this.dictRange[1],this.dictIndex=t=this.lowerBound;this.lowerBound<=this.upperBound?tthis.upperBound;this.dictIndex=this.lowerBound<=this.upperBound?t+=1:t-=1)this.dict.push(String.fromCharCode(this.dictIndex))})}if(o){const t=.5;this.setDictionary(this.dict.sort(()=>Math.random()-t))}else this.setDictionary(this.dict);return this.debug=e.debug,this.log(this.dict),this.log("Generator instantiated with Dictionary Size "+this.dictLength),new Proxy(this,{apply:(t,e,i)=>this.randomUUID(...i)})}log(...t){const e=[...t];if(e[0]="[short-unique-id] "+t[0],!0===this.debug&&"undefined"!=typeof console&&null!==console)return console.log(...e)}setDictionary(t){this.dict=t,this.dictLength=this.dict.length,this.counter=0}seq(){return this.sequentialUUID()}sequentialUUID(){let t,e,i="";for(t=this.counter;e=t%this.dictLength,t=Math.trunc(t/this.dictLength),i+=this.dict[e],0!==t;);return this.counter+=1,i}randomUUID(t=this.uuidLength||6){let e,i,n,s;if(null==t||t<1)throw new Error("Invalid UUID Length Provided");for(e="",s=n=0;0<=t?nt;s=0<=t?n+=1:n-=1)i=parseInt((Math.random()*this.dictLength).toFixed(0),10)%this.dictLength,e+=this.dict[i];return e}availableUUIDs(t=this.uuidLength){return parseFloat(Math.pow([...new Set(this.dict)].length,t).toFixed(0))}approxMaxBeforeCollision(t=this.availableUUIDs(this.uuidLength)){return parseFloat(Math.sqrt(Math.PI/2*t).toFixed(20))}collisionProbability(t=this.availableUUIDs(this.uuidLength),e=this.uuidLength){return parseFloat((this.approxMaxBeforeCollision(t)/this.availableUUIDs(e)).toFixed(20))}uniqueness(t=this.availableUUIDs(this.uuidLength)){const e=parseFloat((1-this.approxMaxBeforeCollision(t)/t).toFixed(20));return e>1?1:e<0?0:e}getVersion(){return this.version}})}}}));const r=s("mod",!1);i.default=r.default},{}]},{},[1]),ShortUniqueId=__suid_module(1).default; diff --git a/docs/classes/shortuniqueid.html b/docs/classes/shortuniqueid.html index 50d3cbe..a3a6a9e 100644 --- a/docs/classes/shortuniqueid.html +++ b/docs/classes/shortuniqueid.html @@ -4,7 +4,7 @@ Short Unique ID - Short UUID Generator - + @@ -38,7 +38,7 @@
  • Preparing search index...
  • The search index is not available
  • - short-unique-id - v3.1.5 + short-unique-id - v3.2.0
    diff --git a/docs/globals.html b/docs/globals.html index 847d701..0499751 100644 --- a/docs/globals.html +++ b/docs/globals.html @@ -4,7 +4,7 @@ Short Unique ID - Short UUID Generator - + @@ -38,7 +38,7 @@
  • Preparing search index...
  • The search index is not available
  • - short-unique-id - v3.1.5 + short-unique-id - v3.2.0
    @@ -63,7 +63,7 @@
    -

    short-unique-id - v3.1.5

    +

    short-unique-id - v3.2.0

    diff --git a/docs/index.html b/docs/index.html index 7b4dfc6..a2b78cc 100644 --- a/docs/index.html +++ b/docs/index.html @@ -4,7 +4,7 @@ Short Unique ID - Short UUID Generator - + @@ -38,7 +38,7 @@
  • Preparing search index...
  • The search index is not available
  • - short-unique-id - v3.1.5 + short-unique-id - v3.2.0
    @@ -63,7 +63,7 @@
    -

    short-unique-id - v3.1.5

    +

    short-unique-id - v3.2.0

    diff --git a/lib/short-unique-id.js b/lib/short-unique-id.js index bd69924..83d20d5 100644 --- a/lib/short-unique-id.js +++ b/lib/short-unique-id.js @@ -104,7 +104,7 @@ System.register("version", [], function (exports_1, context_1) { return { setters: [], execute: function () { - exports_1("default", '3.1.5'); + exports_1("default", '3.2.0'); } }; }); diff --git a/lib/version.js b/lib/version.js index c43495d..0968bc9 100644 --- a/lib/version.js +++ b/lib/version.js @@ -104,7 +104,7 @@ System.register("version", [], function (exports_1, context_1) { return { setters: [], execute: function () { - exports_1("default", '3.1.5'); + exports_1("default", '3.2.0'); } }; }); diff --git a/package.json b/package.json index 8b097bb..7f202e8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "short-unique-id", - "version": "3.1.5", + "version": "3.2.0", "description": "Generate random or sequential UUID of any length", "keywords": [ "short", @@ -34,8 +34,8 @@ "dist:build": "yarn lib:build && rm -rf ./dist/* ; echo 'var __suid_module = ' > ./dist/short-unique-id.js && browserify ./lib/short-unique-id.js >> ./dist/short-unique-id.js && echo 'var ShortUniqueId = __suid_module(1)[\"default\"];' >> ./dist/short-unique-id.js && minify ./dist/short-unique-id.js > ./dist/short-unique-id.min.js", "test": "cd short_uuid && deno test && cd .. && yarn link && yarn link short-unique-id && node ./runkit.js", "lint": "tslint ./short_uuid/*.ts", - "prepare:release": "yarn gen:typings && yarn lint && yarn lib:build && yarn dist:build && yarn test && yarn gen:docs", - "release": "standard-version" + "prepare:release": "yarn gen:typings && yarn lint && yarn lib:build && yarn dist:build && yarn test && cd short_uuid && git commit -am \"release v$(jq -r .version package.json)\" && cd .. && git add short_uuid && yarn gen:docs", + "release": "standard-version -a" }, "husky": { "hooks": { diff --git a/short_uuid b/short_uuid index 03d0346..2564aa8 160000 --- a/short_uuid +++ b/short_uuid @@ -1 +1 @@ -Subproject commit 03d03465371218550bb1ae40d2539b02be67f470 +Subproject commit 2564aa85473096daaaccd40bd60f99d23bb90f0e