short-unique-id
Advanced tools
Comparing version 3.0.1 to 3.0.2
@@ -116,3 +116,3 @@ var __suid_module = | ||
execute: function () { | ||
exports_1("default", "3.0.1"); | ||
exports_1("default", "3.0.2"); | ||
}, | ||
@@ -178,4 +178,6 @@ }; | ||
* import ShortUniqueId from 'https://cdn.jsdelivr.net/npm/short-unique-id@latest/short_uuid/mod.ts'; | ||
* // ES6 Import | ||
* | ||
* // ES6 / TypeScript Import | ||
* import ShortUniqueId from 'short-unique-id'; | ||
* | ||
* //or Node.js require | ||
@@ -182,0 +184,0 @@ * const {default: ShortUniqueId} = require('short-unique-id'); |
@@ -1,1 +0,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<n.length;o++)s(n[o]);return s}({1:[function(t,e,i){"use strict";let n,s,r;Object.defineProperty(i,"__esModule",{value:!0}),(()=>{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)}u<i.length&&r.push(...i.slice(u)),s=r.reverse().join("/")}return e.has(s)?h(s):Promise.resolve().then(()=>t(i))}(n,i),meta:{url:i,main:n}}}function o(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})}}function u(t){for(const[n,s]of e.entries()){const{f:e,exp:r}=s,{execute:u,setters:h}=e(o(r),i(n,n===t));delete s.f,s.e=u,s.s=h}}async function h(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.length;e++)n[e](await h(t[e]));const s=e();s&&await s}return i.exp}n={register(t,i,n){e.set(t,{d:i,f:n,exp:{}})}},s=async t=>(n=s=r=void 0,u(t),h(t)),r=t=>(n=s=r=void 0,u(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;i<s.length;i++)s[i](t(e[i]));i()}return n.exp}(t))})(),n.register("version",[],(function(t,e){e&&e.id;return{setters:[],execute:function(){t("default","3.0.1")}}})),n.register("mod",["version"],(function(t,e){var i,n,s;e&&e.id;return{setters:[function(t){i=t}],execute:function(){6,48,58,97,123,65,91,n={digits:[48,58],lowerCase:[97,123],upperCase:[65,91]},s={dictionary:[],shuffle:!0,debug:!1,length:6},t("default",class extends Function{constructor(t={}){super("...args","return this.randomUUID(...args)"),this.dictIndex=0,this.dictRange=[],this.lowerBound=0,this.upperBound=0,this.dictLength=0;const e={...s,...t};this.counter=0,this.debug=!1,this.dict=[],this.version=i.default;const{dictionary:r,shuffle:o,length:u}=e;if(this.uuidLength=u,r&&r.length>1)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?t<this.upperBound:t>this.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);this.debug=e.debug,this.log(this.dict),this.log("Generator instantiated with Dictionary Size "+this.dictLength);const h=this.bind(this);return Object.getOwnPropertyNames(this).forEach(t=>{if(!/arguments|caller|callee|length|name|prototype/.test(t)){const e=t;h[t]=this[e]}}),h}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?n<t:n>t;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 o=r("mod");i.default=o.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<n.length;o++)s(n[o]);return s}({1:[function(t,e,i){"use strict";let n,s,r;Object.defineProperty(i,"__esModule",{value:!0}),(()=>{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)}u<i.length&&r.push(...i.slice(u)),s=r.reverse().join("/")}return e.has(s)?h(s):Promise.resolve().then(()=>t(i))}(n,i),meta:{url:i,main:n}}}function o(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})}}function u(t){for(const[n,s]of e.entries()){const{f:e,exp:r}=s,{execute:u,setters:h}=e(o(r),i(n,n===t));delete s.f,s.e=u,s.s=h}}async function h(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.length;e++)n[e](await h(t[e]));const s=e();s&&await s}return i.exp}n={register(t,i,n){e.set(t,{d:i,f:n,exp:{}})}},s=async t=>(n=s=r=void 0,u(t),h(t)),r=t=>(n=s=r=void 0,u(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;i<s.length;i++)s[i](t(e[i]));i()}return n.exp}(t))})(),n.register("version",[],(function(t,e){e&&e.id;return{setters:[],execute:function(){t("default","3.0.2")}}})),n.register("mod",["version"],(function(t,e){var i,n,s;e&&e.id;return{setters:[function(t){i=t}],execute:function(){6,48,58,97,123,65,91,n={digits:[48,58],lowerCase:[97,123],upperCase:[65,91]},s={dictionary:[],shuffle:!0,debug:!1,length:6},t("default",class extends Function{constructor(t={}){super("...args","return this.randomUUID(...args)"),this.dictIndex=0,this.dictRange=[],this.lowerBound=0,this.upperBound=0,this.dictLength=0;const e={...s,...t};this.counter=0,this.debug=!1,this.dict=[],this.version=i.default;const{dictionary:r,shuffle:o,length:u}=e;if(this.uuidLength=u,r&&r.length>1)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?t<this.upperBound:t>this.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);this.debug=e.debug,this.log(this.dict),this.log("Generator instantiated with Dictionary Size "+this.dictLength);const h=this.bind(this);return Object.getOwnPropertyNames(this).forEach(t=>{if(!/arguments|caller|callee|length|name|prototype/.test(t)){const e=t;h[t]=this[e]}}),h}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?n<t:n>t;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 o=r("mod");i.default=o.default},{}]},{},[1]),ShortUniqueId=__suid_module(1).default; |
@@ -114,3 +114,3 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. | ||
execute: function () { | ||
exports_1("default", "3.0.1"); | ||
exports_1("default", "3.0.2"); | ||
}, | ||
@@ -176,4 +176,6 @@ }; | ||
* import ShortUniqueId from 'https://cdn.jsdelivr.net/npm/short-unique-id@latest/short_uuid/mod.ts'; | ||
* // ES6 Import | ||
* | ||
* // ES6 / TypeScript Import | ||
* import ShortUniqueId from 'short-unique-id'; | ||
* | ||
* //or Node.js require | ||
@@ -180,0 +182,0 @@ * const {default: ShortUniqueId} = require('short-unique-id'); |
@@ -114,3 +114,3 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. | ||
execute: function () { | ||
exports_1("default", "3.0.1"); | ||
exports_1("default", "3.0.2"); | ||
}, | ||
@@ -117,0 +117,0 @@ }; |
{ | ||
"name": "short-unique-id", | ||
"version": "3.0.1", | ||
"version": "3.0.2", | ||
"description": "Generate random or sequential UUID of any length", | ||
@@ -17,3 +17,3 @@ "keywords": [ | ||
"module": "lib/short-unique-id", | ||
"typings": "short_uuid/mod", | ||
"typings": "typings/short-unique-id", | ||
"homepage": "https://jeanlescure.github.io/short-unique-id/", | ||
@@ -28,6 +28,8 @@ "repository": { | ||
"gen:docs": "cd short_uuid && typedoc --gaID UA-159642755-1 --readme ../README.md --theme ../node_modules/short_uuid_typedoc_template/bin/default --out ../docs . && cd .. && cp -r ./assets ./docs && mv ./docs/assets/favicon.ico ./docs/ && echo shortunique.id > ./docs/CNAME", | ||
"gen:typings": "cd short_uuid && ../node_modules/typescript/bin/tsc --declaration --emitDeclarationOnly mod.ts ; mv mod.d.ts ../typings/short-unique-id.d.ts", | ||
"lib:build": "yarn gen:version && rm ./lib/* ; mkdir -p tmp && cd short_uuid && deno bundle mod.ts ../tmp/mod.js && deno bundle version.ts ../tmp/version.js && cd .. && sucrase ./tmp -d ./lib -t imports && mv ./lib/mod.js ./lib/short-unique-id.js && rm -rf ./tmp", | ||
"dist:build": "yarn lib:build && rm ./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" | ||
"lint": "tslint ./short_uuid/*.ts", | ||
"prepare:release": "yarn gen:typings && yarn lint && yarn lib:build && yarn dist:build && yarn test && yarn gen:docs" | ||
}, | ||
@@ -34,0 +36,0 @@ "devDependencies": { |
@@ -19,3 +19,3 @@ # Short Unique ID (UUID) Generating Library | ||
// ES6 Import | ||
// ES6 / TypeScript Import | ||
import ShortUniqueId from 'short-unique-id'; | ||
@@ -145,2 +145,4 @@ | ||
All feature development must happen under `./short_uuid/mod.ts`. | ||
Tests run using [Deno](https://deno.land/std/testing/): | ||
@@ -147,0 +149,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
200
427568
41
4007