diff --git a/README.md b/README.md index 140cda5..1248966 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ -# Short Unique ID Generator +# Short Unique ID (UUID) Generating Library + +(Try out the [online generator](https://jeanlescure.github.io/short-unique-id/)) + ## With ES6 imports, Node.js, and browser support This is a straight up manual transpilation to ES6 of the [short-uid](https://github.com/serendipious/nodejs-short-uid) npm package by [Ankit Kuwadekar](https://github.com/serendipious/). diff --git a/build/short-unique-id.min.js b/build/short-unique-id.min.js new file mode 100644 index 0000000..caed593 --- /dev/null +++ b/build/short-unique-id.min.js @@ -0,0 +1,2 @@ +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("short-unique-id",[],e):"object"==typeof exports?exports["short-unique-id"]=e():t["short-unique-id"]=e()}(window,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){t.exports=n(1)},function(t,e,n){"use strict";function r(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e0&&void 0!==arguments[0]?arguments[0]:{};o(this,t),i(this,"counter",0),i(this,"debug",void 0),i(this,"dict",[]),i(this,"log",(function(){for(var t=arguments.length,e=new Array(t),o=0;o0&&void 0!==arguments[0]?arguments[0]:6;if(null==o||o<1)throw new Error("Invalid UUID Length Provided");for(t="",r=0;0<=o?ro;0<=o?r+=1:r-=1)e=parseInt(Math.random()*n.dictLength)%n.dictLength,t+=n.dict[e];return t})),this.dictIndex=e=0,Object.keys(u).forEach((function(t){for(n.dictRange=u[t],n.lowerBound=n.dictRange[0],n.upperBound=n.dictRange[1],n.dictIndex=e=n.lowerBound;n.lowerBound<=n.upperBound?en.upperBound;n.dictIndex=n.lowerBound<=n.upperBound?e+=1:e-=1)n.dict.push(String.fromCharCode(n.dictIndex))})),this.dict=this.dict.sort((function(){return Math.random()-.5})),this.dictLength=this.dict.length,this.counter=0,this.debug=c.debug,this.log(this.dict),this.log("Generator instantiated with Dictionary Size ".concat(this.dictLength))}}])})); +//# sourceMappingURL=short-unique-id.min.js.map \ No newline at end of file diff --git a/build/short-unique-id.min.js.map b/build/short-unique-id.min.js.map new file mode 100644 index 0000000..699fa39 --- /dev/null +++ b/build/short-unique-id.min.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["webpack://short-unique-id/webpack/universalModuleDefinition","webpack://short-unique-id/webpack/bootstrap","webpack://short-unique-id/./src/index.js"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","DICT_RANGES","digits","lowerCase","upperCase","ShortUniqueId","options","args","finalArgs","debug","console","log","dict","counterDiv","counterRem","id","counter","dictLength","parseInt","randomPartIdx","j","uuidLength","Error","Math","random","this","dictIndex","keys","forEach","rangeType","dictRange","lowerBound","upperBound","push","String","fromCharCode","sort","length"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OAC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GAAK,EAAGA,GAAK,EAEzCD,EAAgBD,SAASK,KAAKC,SAAW,EAAKP,YAAc,EAAKA,WACjEF,GAAM,EAAKH,KAAKO,GAKlB,OAAOJ,KApFPU,KAAKC,UAAYzD,EAAI,EACrBU,OAAOgD,KAAK1B,GAAa2B,SAAQ,SAACC,GAMhC,IALA,EAAKC,UAAY7B,EAAY4B,GAE7B,EAAKE,WAAa,EAAKD,UAAU,GACjC,EAAKE,WAAa,EAAKF,UAAU,GAG/B,EAAKJ,UAAYzD,EAAI,EAAK8D,WAC1B,EAAKA,YAAc,EAAKC,WAAa/D,EAAI,EAAK+D,WAAa/D,EAAI,EAAK+D,WACpE,EAAKN,UAAY,EAAKK,YAAc,EAAKC,WAAa/D,GAAK,EAAIA,GAAK,EAEpE,EAAK2C,KAAKqB,KAAKC,OAAOC,aAAa,EAAKT,eAM5CD,KAAKb,KAAOa,KAAKb,KAAKwB,MAAK,kBAAMb,KAAKC,SAAW,MAGjDC,KAAKR,WAAaQ,KAAKb,KAAKyB,OAC5BZ,KAAKT,QAAU,EACfS,KAAKhB,MAAQH,EAAQG,MACrBgB,KAAKd,IAAIc,KAAKb,MACda,KAAKd,IAAL,sDAAyDc,KAAKR","file":"short-unique-id.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"short-unique-id\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"short-unique-id\"] = factory();\n\telse\n\t\troot[\"short-unique-id\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","const DEFAULT_RANDOM_ID_LEN = 6;\n\nconst DICT_RANGES = {\n digits: [48, 58],\n lowerCase: [97, 123],\n upperCase: [65, 91],\n};\n\nclass ShortUniqueId {\n counter = 0;\n\n debug;\n\n dict = [];\n\n /* eslint-disable consistent-return */\n log = (...args) => {\n const finalArgs = [...args];\n finalArgs[0] = `[short-unique-id] ${args[0]}`;\n /* eslint-disable no-console */\n if (this.debug === true) {\n if (typeof console !== 'undefined' && console !== null) {\n return console.log(...finalArgs);\n }\n }\n /* eslint-enable no-console */\n };\n /* eslint-enable consistent-return */\n\n constructor(options = {}) {\n let i;\n /* eslint-disable no-multi-assign */\n this.dictIndex = i = 0;\n Object.keys(DICT_RANGES).forEach((rangeType) => {\n this.dictRange = DICT_RANGES[rangeType];\n /* eslint-disable prefer-destructuring */\n this.lowerBound = this.dictRange[0];\n this.upperBound = this.dictRange[1];\n /* eslint-enable prefer-destructuring */\n for (\n this.dictIndex = i = this.lowerBound;\n this.lowerBound <= this.upperBound ? i < this.upperBound : i > this.upperBound;\n this.dictIndex = this.lowerBound <= this.upperBound ? i += 1 : i -= 1\n ) {\n this.dict.push(String.fromCharCode(this.dictIndex));\n }\n });\n /* eslint-enable no-multi-assign */\n\n // Shuffle Dictionary for removing selection bias.\n this.dict = this.dict.sort(() => Math.random() - 0.5);\n\n // Cache Dictionary Length for future usage.\n this.dictLength = this.dict.length;// Resets internal counter.\n this.counter = 0;\n this.debug = options.debug;\n this.log(this.dict);\n this.log((`Generator instantiated with Dictionary Size ${this.dictLength}`));\n }\n\n getDict = () => this.dict;\n\n /**\n * Generates UUID based on internal counter that's incremented after each ID generation.\n */\n sequentialUUID = () => {\n let counterDiv;\n let counterRem;\n let id;\n id = '';\n counterDiv = this.counter;\n /* eslint-disable no-constant-condition */\n while (true) {\n counterRem = counterDiv % this.dictLength;\n counterDiv = parseInt(counterDiv / this.dictLength, 10);\n id += this.dict[counterRem];\n if (counterDiv === 0) {\n break;\n }\n }\n /* eslint-enable no-constant-condition */\n this.counter += 1;\n return id;\n };\n\n /**\n * Generates UUID by creating each part randomly.\n * @param {Integer} uuidLength Desired UUID length.\n */\n randomUUID = (uuidLength = DEFAULT_RANDOM_ID_LEN) => {\n let id;\n let randomPartIdx;\n let j;\n\n /* eslint-disable no-unused-vars */\n let idIndex;\n /* eslint-enable no-unused-vars */\n\n if ((uuidLength === null || typeof uuidLength === 'undefined') || uuidLength < 1) {\n throw new Error('Invalid UUID Length Provided');\n }\n\n // Generate random ID parts from Dictionary.\n id = '';\n /* eslint-disable */\n for (\n idIndex = j = 0;\n 0 <= uuidLength ? j < uuidLength : j > uuidLength;\n idIndex = 0 <= uuidLength ? j += 1: j -= 1\n ) {\n randomPartIdx = parseInt(Math.random() * this.dictLength) % this.dictLength;\n id += this.dict[randomPartIdx];\n }\n /* eslint-enable */\n\n // Return random generated ID.\n return id;\n };\n}\n\nexport default ShortUniqueId;\n"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/short-unique-id.min.js.map b/dist/short-unique-id.min.js.map new file mode 100644 index 0000000..699fa39 --- /dev/null +++ b/dist/short-unique-id.min.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["webpack://short-unique-id/webpack/universalModuleDefinition","webpack://short-unique-id/webpack/bootstrap","webpack://short-unique-id/./src/index.js"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","DICT_RANGES","digits","lowerCase","upperCase","ShortUniqueId","options","args","finalArgs","debug","console","log","dict","counterDiv","counterRem","id","counter","dictLength","parseInt","randomPartIdx","j","uuidLength","Error","Math","random","this","dictIndex","keys","forE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IAAIC,MAAM,gCAMlB,IAFAP,EAAK,GAGOK,EAAI,EACd,GAAKC,EAAaD,EAAIC,EAAaD,EAAIC,EAC7B,GAAKA,EAAaD,GAAK,EAAGA,GAAK,EAEzCD,EAAgBD,SAASK,KAAKC,SAAW,EAAKP,YAAc,EAAKA,WACjEF,GAAM,EAAKH,KAAKO,GAKlB,OAAOJ,KApFPU,KAAKC,UAAYzD,EAAI,EACrBU,OAAOgD,KAAK1B,GAAa2B,SAAQ,SAACC,GAMhC,IALA,EAAKC,UAAY7B,EAAY4B,GAE7B,EAAKE,WAAa,EAAKD,UAAU,GACjC,EAAKE,WAAa,EAAKF,UAAU,GAG/B,EAAKJ,UAAYzD,EAAI,EAAK8D,WAC1B,EAAKA,YAAc,EAAKC,WAAa/D,EAAI,EAAK+D,WAAa/D,EAAI,EAAK+D,WACpE,EAAKN,UAAY,EAAKK,YAAc,EAAKC,WAAa/D,GAAK,EAAIA,GAAK,EAEpE,EAAK2C,KAAKqB,KAAKC,OAAOC,aAAa,EAAKT,eAM5CD,KAAKb,KAAOa,KAAKb,KAAKwB,MAAK,kBAAMb,KAAKC,SAAW,MAGjDC,KAAKR,WAAaQ,KAAKb,KAAKyB,OAC5BZ,KAAKT,QAAU,EACfS,KAAKhB,MAAQH,EAAQG,MACrBgB,KAAKd,IAAIc,KAAKb,MACda,KAAKd,IAAL,sDAAyDc,KAAKR","file":"short-unique-id.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"short-unique-id\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"short-unique-id\"] = factory();\n\telse\n\t\troot[\"short-unique-id\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","const DEFAULT_RANDOM_ID_LEN = 6;\n\nconst DICT_RANGES = {\n digits: [48, 58],\n lowerCase: [97, 123],\n upperCase: [65, 91],\n};\n\nclass ShortUniqueId {\n counter = 0;\n\n debug;\n\n dict = [];\n\n /* eslint-disable consistent-return */\n log = (...args) => {\n const finalArgs = [...args];\n finalArgs[0] = `[short-unique-id] ${args[0]}`;\n /* eslint-disable no-console */\n if (this.debug === true) {\n if (typeof console !== 'undefined' && console !== null) {\n return console.log(...finalArgs);\n }\n }\n /* eslint-enable no-console */\n };\n /* eslint-enable consistent-return */\n\n constructor(options = {}) {\n let i;\n /* eslint-disable no-multi-assign */\n this.dictIndex = i = 0;\n Object.keys(DICT_RANGES).forEach((rangeType) => {\n this.dictRange = DICT_RANGES[rangeType];\n /* eslint-disable prefer-destructuring */\n this.lowerBound = this.dictRange[0];\n this.upperBound = this.dictRange[1];\n /* eslint-enable prefer-destructuring */\n for (\n this.dictIndex = i = this.lowerBound;\n this.lowerBound <= this.upperBound ? i < this.upperBound : i > this.upperBound;\n this.dictIndex = this.lowerBound <= this.upperBound ? i += 1 : i -= 1\n ) {\n this.dict.push(String.fromCharCode(this.dictIndex));\n }\n });\n /* eslint-enable no-multi-assign */\n\n // Shuffle Dictionary for removing selection bias.\n this.dict = this.dict.sort(() => Math.random() - 0.5);\n\n // Cache Dictionary Length for future usage.\n this.dictLength = this.dict.length;// Resets internal counter.\n this.counter = 0;\n this.debug = options.debug;\n this.log(this.dict);\n this.log((`Generator instantiated with Dictionary Size ${this.dictLength}`));\n }\n\n getDict = () => this.dict;\n\n /**\n * Generates UUID based on internal counter that's incremented after each ID generation.\n */\n sequentialUUID = () => {\n let counterDiv;\n let counterRem;\n let id;\n id = '';\n counterDiv = this.counter;\n /* eslint-disable no-constant-condition */\n while (true) {\n counterRem = counterDiv % this.dictLength;\n counterDiv = parseInt(counterDiv / this.dictLength, 10);\n id += this.dict[counterRem];\n if (counterDiv === 0) {\n break;\n }\n }\n /* eslint-enable no-constant-condition */\n this.counter += 1;\n return id;\n };\n\n /**\n * Generates UUID by creating each part randomly.\n * @param {Integer} uuidLength Desired UUID length.\n */\n randomUUID = (uuidLength = DEFAULT_RANDOM_ID_LEN) => {\n let id;\n let randomPartIdx;\n let j;\n\n /* eslint-disable no-unused-vars */\n let idIndex;\n /* eslint-enable no-unused-vars */\n\n if ((uuidLength === null || typeof uuidLength === 'undefined') || uuidLength < 1) {\n throw new Error('Invalid UUID Length Provided');\n }\n\n // Generate random ID parts from Dictionary.\n id = '';\n /* eslint-disable */\n for (\n idIndex = j = 0;\n 0 <= uuidLength ? j < uuidLength : j > uuidLength;\n idIndex = 0 <= uuidLength ? j += 1: j -= 1\n ) {\n randomPartIdx = parseInt(Math.random() * this.dictLength) % this.dictLength;\n id += this.dict[randomPartIdx];\n }\n /* eslint-enable */\n\n // Return random generated ID.\n return id;\n };\n}\n\nexport default ShortUniqueId;\n"],"sourceRoot":""} \ No newline at end of file