{"_id":"uid-generator","_rev":"12-078868749f2f334896b4e3094d9a9b1a","name":"uid-generator","description":"Generates cryptographically strong pseudo-random UIDs with custom size and base-encoding","dist-tags":{"latest":"2.0.0"},"versions":{"0.1.0":{"name":"uid-generator","version":"0.1.0","description":"Generates cryptographically strong pseudo-random UIDs with custom size and base-encoding","main":"index.js","files":["index.js"],"engines":{"node":">=4"},"scripts":{"test":"grunt"},"repository":{"type":"git","url":"git+https://github.com/nwoltman/node-uid-generator.git"},"keywords":["uid","generator","random","token","unique","crypto","strong","base","encoding"],"author":{"name":"Nathan Woltman","email":"nwoltman@outlook.com"},"license":"MIT","bugs":{"url":"https://github.com/nwoltman/node-uid-generator/issues"},"homepage":"https://github.com/nwoltman/node-uid-generator","devDependencies":{"coveralls":"^2.11.15","grunt":"^1.0.1","grunt-eslint":"^19.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-mocha-test":"^0.13.2","istanbul":"^0.4.5","jit-grunt":"^0.10.0","mocha":"^3.1.2","should":"^11.1.1"},"gitHead":"fb4a1d1a877ec4541d28560903e71bef5d864bc3","_id":"uid-generator@0.1.0","_shasum":"1466810b784d1fea4251069a64d8c7215fc700ac","_from":".","_npmVersion":"2.15.11","_nodeVersion":"4.6.2","_npmUser":{"name":"nwoltman","email":"nwoltman@outlook.com"},"dist":{"shasum":"1466810b784d1fea4251069a64d8c7215fc700ac","tarball":"https://registry.npmjs.org/uid-generator/-/uid-generator-0.1.0.tgz","integrity":"sha512-/Qdncu65uhTcG0drMBlK3L8h+LXDT02hQMyOOulg71Lli5a/fa4Ejt3hcjKLlVl0x8HmmSed/07C6G12cPuTbQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDykFAsrE7X9XRS9rNd6TlQd0WFLUpdR4+chBqddlfG3wIgKVFfZ/JScLswb0FHL0jV2XvTjyclgAHrA9mgYsZ2b4w="}]},"maintainers":[{"name":"nwoltman","email":"nwoltman@outlook.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/uid-generator-0.1.0.tgz_1479881834068_0.5097401915118098"},"directories":{}},"0.1.1":{"name":"uid-generator","version":"0.1.1","description":"Generates cryptographically strong pseudo-random UIDs with custom size and base-encoding","main":"index.js","files":["index.js"],"engines":{"node":">=4"},"scripts":{"test":"grunt"},"repository":{"type":"git","url":"git+https://github.com/nwoltman/node-uid-generator.git"},"keywords":["uid","generator","random","token","unique","crypto","strong","base","encoding"],"author":{"name":"Nathan Woltman","email":"nwoltman@outlook.com"},"license":"MIT","bugs":{"url":"https://github.com/nwoltman/node-uid-generator/issues"},"homepage":"https://github.com/nwoltman/node-uid-generator","devDependencies":{"coveralls":"^2.11.15","grunt":"^1.0.1","grunt-eslint":"^19.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-mocha-test":"^0.13.2","istanbul":"^0.4.5","jit-grunt":"^0.10.0","mocha":"^3.1.2","should":"^11.1.1"},"gitHead":"e552c450a203224d09a01d037db41fefef720711","_id":"uid-generator@0.1.1","_shasum":"10bc57734f42a25b14c4b8741d703e14f176a7a1","_from":".","_npmVersion":"2.15.11","_nodeVersion":"4.7.3","_npmUser":{"name":"nwoltman","email":"nwoltman@outlook.com"},"dist":{"shasum":"10bc57734f42a25b14c4b8741d703e14f176a7a1","tarball":"https://registry.npmjs.org/uid-generator/-/uid-generator-0.1.1.tgz","integrity":"sha512-Sq/Dk6j5LuJRzBA4XtscAa3Y9xHFA5/D/UtR7tRaHjEOhJVUy7FKPlV9735LOrcF6LBfaWZq8iwR4AbNfEkbMg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDsetu+j2xHjJXgvQI5+af2zh7ieyvNHuLL6pgwLDcFLQIhAJOdNsrhrrqGDMNpbAEWlK0RlWZWzYwURIy9uQyLB2mn"}]},"maintainers":[{"name":"nwoltman","email":"nwoltman@outlook.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/uid-generator-0.1.1.tgz_1487559323355_0.4361328750383109"},"directories":{}},"1.0.0":{"name":"uid-generator","version":"1.0.0","description":"Generates cryptographically strong pseudo-random UIDs with custom size and base-encoding","main":"index.js","files":["index.js"],"engines":{"node":">=4"},"repository":{"type":"git","url":"git+https://github.com/nwoltman/node-uid-generator.git"},"keywords":["uid","generator","random","token","unique","crypto","strong","base","encoding"],"author":{"name":"Nathan Woltman","email":"nwoltman@outlook.com"},"license":"MIT","bugs":{"url":"https://github.com/nwoltman/node-uid-generator/issues"},"homepage":"https://github.com/nwoltman/node-uid-generator","devDependencies":{"coveralls":"^3.0.0","eslint":"~4.10.0","mocha":"^4.0.1","nyc":"~11.3.0","should":"~13.1.3"},"scripts":{"lint":"eslint index.js test/*.js","test":"eslint index.js test/*.js && nyc --reporter=html --reporter=text-summary mocha","coveralls":"nyc report --reporter=text-lcov | coveralls"},"gitHead":"d9fdecddf1bbf077983db057af4f02acb3fbed7a","_id":"uid-generator@1.0.0","_npmVersion":"5.5.1","_nodeVersion":"9.1.0","_npmUser":{"name":"nwoltman","email":"nwoltman@outlook.com"},"dist":{"integrity":"sha512-tx0ni0iyF4CZVNP8bAxcK3PNmtQcJPdflpy6lVW1lPIhTEuPoKR+o88auoXi3mFKLZ7nItCeMRp9GyFFbZ4f3w==","shasum":"cc4fb69bdcf3b51ca369640d70b0e93b0ecd3d9c","tarball":"https://registry.npmjs.org/uid-generator/-/uid-generator-1.0.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICbpTofs5ZOYjjoa0ywB2iLwamxerL/GvG3svRLA7r9LAiEAm4KGHEF10SEEtaUcCn+m8IcZTT0F4L2YRZHwahmjvLI="}]},"maintainers":[{"name":"nwoltman","email":"nwoltman@outlook.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/uid-generator-1.0.0.tgz_1510084892686_0.892901639919728"},"directories":{}},"2.0.0":{"name":"uid-generator","version":"2.0.0","description":"Generates cryptographically strong pseudo-random UIDs with custom size and base-encoding","main":"index.js","engines":{"node":">=4"},"repository":{"type":"git","url":"git+https://github.com/nwoltman/node-uid-generator.git"},"keywords":["uid","generator","random","token","unique","crypto","strong","base","encoding"],"author":{"name":"Nathan Woltman","email":"nwoltman@outlook.com"},"license":"MIT","bugs":{"url":"https://github.com/nwoltman/node-uid-generator/issues"},"homepage":"https://github.com/nwoltman/node-uid-generator","devDependencies":{"@nwoltman/eslint-config":"~0.2.1","coveralls":"^3.0.4","eslint":"^5.16.0","mocha":"^6.1.4","nyc":"^14.1.1","should":"^13.2.3"},"scripts":{"lint":"eslint index.js test/*.js","test":"eslint index.js test/*.js && nyc --reporter=html --reporter=text-summary mocha","coveralls":"nyc report --reporter=text-lcov | coveralls"},"gitHead":"18bce1089a26e1dc9b1cddbd1ab9ac90fbb0e1ca","_id":"uid-generator@2.0.0","_nodeVersion":"12.4.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-XLRw2UyViQueSbd3dOHkswrg4gA4YuhibKzkFiPkilo6cdKEQqOX3K/Yu6Z2WXVMK+npfMNlSSufVSUifbXoOQ==","shasum":"70e7b882300a4ccd12841e5a857dacada7fd7452","tarball":"https://registry.npmjs.org/uid-generator/-/uid-generator-2.0.0.tgz","fileCount":4,"unpackedSize":12780,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJc+ZHNCRA9TVsSAnZWagAAVmkP/3WY6yntS8kX7BlCVQFo\nn6J2ZDWVIdjsThyphJK53aH6mJN7Oz44G/ffd/2T8/d4SZ3RMJw50QdYBK4c\nybbQSgme/rUBQEuqlMnphj07bxez3TryEnfhDgHRYHoHyVAht4mAzkYQsJnS\nwgHnlL2DJy9zMdQIZCHItYTLQYASzokG1r+bE/gqSjl2GSIIfevNNSC2ooPV\n6GJsVe3TSQt/rrZWu+yCabLiY1DiXWGM98cJ0SrSq0eAG8+vT8LOpAPtbmzr\nCa3QSXRJMaLqb05AJY1O6tOB7cXfxz2NYwyoeWotxJsyp5y5IpOJhnQ+E0NB\n8xmg/jaKBjiG8WFKZz8GwU2wFZyr+/DQ8yvs7foBsRe6+L+3byWwSK+MX7R0\nX7JyySnrlnbzZ8NZ0a8M3kwgwd4oOH54i1iJUNGzSk158+/9DuBSNhOKs/D2\nnnE9FGXKdYyRf2rh5aHn4UNNGGe3nYdP5IdiPzKRU+AsUUZyZCPoNHjFZ6Xa\nVqzLmEKeTe7iKxPz0W6O+OCqshy7cDWQ3XtJDoOTwgprWfjEeov8MxL9sg9a\nxJUi6YC3PcewSj5ynCwwPaT9OldR2xjJ2g7SKglOOlLSEpAQI9QJ7ltsZJMP\ngnWdfY1oRcjrCuKW39aof2EEqWlUpGdcSf5QBd86zTqWKmq3bZ4Li6ZEnrTT\nAZ7C\r\n=DP6F\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCcok+xbLVNOor7U0vLaFrI5cQYYwq0F2PtJPmi6997pwIhAKyTQ3Bd7FuGcDICDZNngL2QzsigDzMdilvRRG8Nkl6R"}]},"maintainers":[{"name":"nwoltman","email":"nwoltman@outlook.com"}],"_npmUser":{"name":"nwoltman","email":"nwoltman@outlook.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/uid-generator_2.0.0_1559859659939_0.7844718280558665"},"_hasShrinkwrap":false}},"readme":"# uid-generator\n\n[![NPM Version](https://img.shields.io/npm/v/uid-generator.svg)](https://www.npmjs.com/package/uid-generator)\n[![Build Status](https://travis-ci.org/nwoltman/node-uid-generator.svg?branch=master)](https://travis-ci.org/nwoltman/node-uid-generator)\n[![Coverage Status](https://coveralls.io/repos/github/nwoltman/node-uid-generator/badge.svg?branch=master)](https://coveralls.io/github/nwoltman/node-uid-generator?branch=master)\n[![devDependency Status](https://david-dm.org/nwoltman/node-uid-generator/dev-status.svg)](https://david-dm.org/nwoltman/node-uid-generator?type=dev)\n\nGenerates cryptographically strong, pseudo-random UIDs with custom size and base-encoding. Generated UIDs are strings that are guaranteed to always be the same length depending on the specified [bit-size](#api).\n\nGreat for generating things like compact API keys and UIDs that are safe to use in URLs and cookies.\n\n**Tip:** The main benefit of this module is the ability to easily generate human-safe UIDs (using [base58](#uidgeneratorbase58--string)) and large UIDs that are more compact (using something like [base94](#uidgeneratorbase94--string)). If you’re just looking to generate URL-safe base64 IDs, the best package for that is [`uid-safe`](https://github.com/crypto-utils/uid-safe).\n\n\n## Installation\n\n```sh\nnpm install uid-generator --save\n# or\nyarn add uid-generator\n```\n\n\n## Usage\n\n```js\nconst UIDGenerator = require('uid-generator');\nconst uidgen = new UIDGenerator(); // Default is a 128-bit UID encoded in base58\n\n// Async with `await`\nawait uidgen.generate(); // -> 'B1q2hUEKmeVp9zWepx9cnp'\n\n// Async with promise\nuidgen.generate()\n  .then(uid => console.log(uid)); // -> 'PXmRJVrtzFAHsxjs7voD5R'\n\n// Async with callback\nuidgen.generate((err, uid) => {\n  if (err) throw err;\n  console.log(uid); // -> '4QhmRwHwwrgFqXULXNtx4d'\n});\n\n// Sync\nuidgen.generateSync(); // -> '8Vw3bgbMMzeYfrQHQ8p3Jr'\n```\n\n\n## API\n\n### new UIDGenerator([bitSize][, baseEncoding])\n\nCreates a new `UIDGenerator` instance that generates `bitSize`-bit or `uidLength`-sized UIDs encoded using the characters in `baseEncoding`.\n\n| Param          | Type     | Default               | Description\n|----------------|--------- |-----------------------|-------------\n| [bitSize]      | `number` | `128`                 | The size of the UID to generate in bits. Must be a multiple of `8`.\n| [baseEncoding] | `string` | `UIDGenerator.BASE58` | One of the `UIDGenerator.BASE##` constants or a custom string of characters to use to encode the UID.\n\n**Note:** If a custom `baseEncoding` that has URL-unsafe characters is used, it is up to you to URL-encode the resulting UID.\n\n**Example**\n\n```js\nnew UIDGenerator();\nnew UIDGenerator(256);\nnew UIDGenerator(UIDGenerator.BASE16);\nnew UIDGenerator(512, UIDGenerator.BASE62);\nnew UIDGenerator('01'); // Custom encoding (base2)\n```\n\n---\n\n### uidgen.generate([cb]) ⇒ `?Promise<string>`\n\nAsynchronously generates a UID.\n\n| Param | Type | Description |\n|-------|------|-------------|\n| [cb] | `?function(error, uid)` | An optional callback that will be called with the results of generating the UID.<br>If not specified, the function will return a promise. |\n\n**Returns**: `?Promise<string>` - A promise that will resolve with the UID or reject with an error. Returns nothing if the `cb` parameter is specified.\n\n**`async`/`await` Example**\n\n```js\nconst uidgen = new UIDGenerator();\n// This must be inside an async function\nconst uid = await uidgen.generate();\n```\n\n**Promise Example**\n\n```js\nconst uidgen = new UIDGenerator();\n\nuidgen.generate()\n  .then(uid => {\n    // Use uid here\n  });\n```\n\n**Callback Example**\n\n```js\nconst uidgen = new UIDGenerator();\n\nuidgen.generate((err, uid) => {\n  if (err) throw err;\n  // Use uid here\n});\n```\n\n---\n\n### uidgen.generateSync() ⇒ `string`\n\nSynchronously generates a UID.\n\n**Returns**: `string` - The generated UID.\n\n**Example**\n\n```js\nconst uidgen = new UIDGenerator();\nconst uid = uidgen.generateSync();\n```\n\n---\n\n### (readonly) uidgen.bitSize : `number`\n\nThe size of the UID that will be generated in bits (the `bitSize` value passed to the `UIDGenerator` constructor).\nIf the `uidLength` parameter is passed to the constructor instead of `bitSize`, `bitSize` is calculated as follows:\n\n```js\nbitSize = Math.ceil(length * Math.log2(base));\n```\n\n**Example**\n\n```js\nnew UIDGenerator().bitSize // -> 128\nnew UIDGenerator(256).bitSize // -> 256\n```\n\n---\n\n### (readonly) uidgen.uidLength : `number`\n\nThe length of the UID string that will be generated. The generated UID will always be this length.\nThis will be the same as the `uidLength` parameter passed to the `UIDGenerator` constructor.\nIf the `uidLength` parameter is not passed to the constructor, it will be calculated using the `bitSize` parameter as follows:\n\n```js\nuidLength = Math.ceil(bitSize / Math.log2(base))\n```\n\n**Example**\n\n```js\nnew UIDGenerator().uidLength // -> 22\nnew UIDGenerator(256, UIDGenerator.BASE62).uidLength // -> 43\n```\n\n---\n\n### (readonly) uidgen.baseEncoding : `string`\n\nThe set of characters used to encode the UID string (the `baseEncoding` value passed to the `UIDGenerator` constructor).\n\n**Example**\n\n```js\nnew UIDGenerator().baseEncoding // -> '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'\nnew UIDGenerator(UIDGenerator.BASE16).baseEncoding // -> '0123456789abcdef'\nnew UIDGenerator('01').baseEncoding // -> '01'\n```\n\n---\n\n### (readonly) uidgen.base : `number`\n\nThe base of the UID that will be generated (which is the number of characters in the `baseEncoding`).\n\n**Example**\n\n```js\nnew UIDGenerator().base // -> 58\nnew UIDGenerator(UIDGenerator.BASE16).base // -> 16\nnew UIDGenerator('01').base // -> 2\n```\n\n---\n\n### UIDGenerator.BASE16 : `string`\n`0123456789abcdef`\n\n### UIDGenerator.BASE36 : `string`\n`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ`\n\n### UIDGenerator.BASE58 : `string`\n`123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`\n\n(all alphanumeric characters except for `0`, `O`, `I`, and `l` — characters easily mistaken for each other)\n\nThe default base.\n\n**Tip:** Use this base to create UIDs that are easy to type in manually.\n\n### UIDGenerator.BASE62 : `string`\n`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`\n\n### UIDGenerator.BASE66 : `string`\n`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-._~`\n\n(all ASCII characters that do not need to be encoded in a URI as specified by [RFC 3986](https://tools.ietf.org/html/rfc3986#section-2.3))\n\n### UIDGenerator.BASE71 : `string`\n`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!'()*-._~`\n\n(all ASCII characters that are not encoded by `encodeURIComponent()`)\n\n### UIDGenerator.BASE94 : `string`\n``!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~``\n\n(all readable ASCII characters)\n","maintainers":[{"name":"nwoltman","email":"nwoltman@outlook.com"}],"time":{"modified":"2022-06-28T03:28:23.152Z","created":"2016-11-23T06:17:14.690Z","0.1.0":"2016-11-23T06:17:14.690Z","0.1.1":"2017-02-20T02:55:25.436Z","1.0.0":"2017-11-07T20:01:33.709Z","2.0.0":"2019-06-06T22:21:00.819Z"},"homepage":"https://github.com/nwoltman/node-uid-generator","keywords":["uid","generator","random","token","unique","crypto","strong","base","encoding"],"repository":{"type":"git","url":"git+https://github.com/nwoltman/node-uid-generator.git"},"author":{"name":"Nathan Woltman","email":"nwoltman@outlook.com"},"bugs":{"url":"https://github.com/nwoltman/node-uid-generator/issues"},"license":"MIT","readmeFilename":"README.md","users":{"pagoru":true,"dallinrparker":true,"mohamadou":true}}