Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

short-unique-id

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

short-unique-id - npm Package Compare versions

Comparing version 3.0.0-alpha to 3.0.0-rc1

assets/favicon.ico

10

dist/short-unique-id.js

@@ -117,4 +117,4 @@ var __suid_module =

execute: function () {
exports_1("default", { "version": "3.0.0-alpha" });
exports_1("version", version = "3.0.0-alpha");
exports_1("default", { "version": "3.0.0-rc1" });
exports_1("version", version = "3.0.0-rc1");
}

@@ -168,5 +168,7 @@ };

* ```js
* // Import
* // Deno (web module) Import
* import ShortUniqueId from 'https://cdn.jsdelivr.net/npm/short-unique-id@3.0.0-rc1/short_uuid/mod.ts';
* // ES6 Import
* import ShortUniqueId from 'short-unique-id';
* //or
* //or Node.js require
* const ShortUniqueId = require('short-unique-id');

@@ -173,0 +175,0 @@ *

2

dist/short-unique-id.min.js

@@ -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",{version:"3.0.0-alpha"}),t("version","3.0.0-alpha")}}})),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.version;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 c=i[o]={exports:{}};e[o][0].call(c.exports,(function(t){return s(e[o][1][t]||t)}),c,c.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",{version:"3.0.0-rc1"}),t("version","3.0.0-rc1")}}})),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.version;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;

@@ -115,4 +115,4 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.

execute: function () {
exports_1("default", { "version": "3.0.0-alpha" });
exports_1("version", version = "3.0.0-alpha");
exports_1("default", { "version": "3.0.0-rc1" });
exports_1("version", version = "3.0.0-rc1");
}

@@ -166,5 +166,7 @@ };

* ```js
* // Import
* // Deno (web module) Import
* import ShortUniqueId from 'https://cdn.jsdelivr.net/npm/short-unique-id@3.0.0-rc1/short_uuid/mod.ts';
* // ES6 Import
* import ShortUniqueId from 'short-unique-id';
* //or
* //or Node.js require
* const ShortUniqueId = require('short-unique-id');

@@ -171,0 +173,0 @@ *

@@ -1,1 +0,1 @@

{"version": "3.0.0-alpha"}
{"version": "3.0.0-rc1"}
{
"name": "short-unique-id",
"version": "3.0.0-alpha",
"version": "3.0.0-rc1",
"description": "Generate random or sequential UUID of any length",

@@ -25,3 +25,3 @@ "keywords": [

"gen:version": "echo \"{\\\"version\\\": `jq .version package.json`}\" > short_uuid/version.json",
"gen:docs": "cd short_uuid && typedoc --readme ../README.md --theme ../node_modules/short_uuid_typedoc_template/bin/default --out ../docs . && cd .. && cp -r ./assets ./docs",
"gen:docs": "cd short_uuid && typedoc --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",
"lib:build": "yarn gen:version && rm ./lib/* ; mkdir -p tmp && cd short_uuid && deno bundle mod.ts ../tmp/mod.js && cd .. && sucrase ./tmp -d ./lib -t imports && mv ./lib/mod.js ./lib/short-unique-id.js && cp short_uuid/version.json ./lib && rm -rf ./tmp",

@@ -35,3 +35,3 @@ "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",

"minify": "^5.1.1",
"short_uuid_typedoc_template": "^1.0.3",
"short_uuid_typedoc_template": "^1.0.5",
"sucrase": "^3.13.0",

@@ -38,0 +38,0 @@ "tslint": "^6.1.1",

@@ -36,4 +36,4 @@ # Short Unique ID (UUID) Generating Library

<a target="_blank" href="https://shortunique.id/classes/shortuniqueid.html#collisionprobability">API Reference</a>.
```
## V3.x

@@ -40,0 +40,0 @@

@@ -1,2 +0,2 @@

// Copyright 2017-2020 the Short Unique ID authors. All rights reserved. Apache license.
// Copyright 2017-2020 the Short Unique ID authors. All rights reserved. Apache 2.0 license.
import { version } from './version.json';

@@ -72,5 +72,7 @@

* ```js
* // Import
* // Deno (web module) Import
* import ShortUniqueId from 'https://cdn.jsdelivr.net/npm/short-unique-id@3.0.0-rc1/short_uuid/mod.ts';
* // ES6 Import
* import ShortUniqueId from 'short-unique-id';
* //or
* //or Node.js require
* const ShortUniqueId = require('short-unique-id');

@@ -77,0 +79,0 @@ *

# Deno Short UUID Module
This is
This is a random UUID reneration module which allows you to set your own dictionary and length.
## Platform Support
This repo is pulled as a submodule by the npm package [short-unique-id](https://github.com/jeanlescure/short-unique-id). This allows us to support the following platforms through TypeScript and `deno bundle`:
- Deno
- Node.js
- Browsers
## Documentation
You can find the docs and online generator at:
[https://shortunique.id](https://shortunique.id)
## Example
```js
import ShortUniqueId from 'https://cdn.jsdelivr.net/npm/short-unique-id@3.0.0-rc1/short_uuid/mod.ts';
const uid = new ShortUniqueId();
// Random UUID of length 6 (default)
console.log(uid()); // x6trff
// Random UUID of length 12
console.log(uid(12)); // wwL44UU5K0z3
const abUid = new ShortUniqueId({
dictionary: ['a', 'b'],
shuffle: false,
});
// Sequential UUID
console.log(abUid.seq()); // a
console.log(abUid.seq()); // b
console.log(abUid.seq()); // ab
console.log(abUid.seq()); // bb
console.log(abUid.seq()); // aab
// ...
```

@@ -1,1 +0,1 @@

{"version": "3.0.0-alpha"}
{"version": "3.0.0-rc1"}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc