{"_id":"@basementuniverse/shortuid","_rev":"3-88ad0d5db0f702303240fac4c2d4bae9","name":"@basementuniverse/shortuid","dist-tags":{"latest":"1.1.0"},"versions":{"0.1.0":{"name":"@basementuniverse/shortuid","version":"0.1.0","keywords":["short","id","uid","unique"],"author":{"url":"https://gordonlarrigan.com","name":"Gordon Larrigan","email":"gordonlarrigan@gmail.com"},"license":"MIT","_id":"@basementuniverse/shortuid@0.1.0","maintainers":[{"name":"basementuniverse","email":"gordonlarrigan@gmail.com"}],"homepage":"https://github.com/basementuniverse/shortuid#readme","bugs":{"url":"https://github.com/basementuniverse/shortuid/issues"},"dist":{"shasum":"f5b67065dfaf1e0e814ca09f35a76ce1c2dc1021","tarball":"https://registry.npmjs.org/@basementuniverse/shortuid/-/shortuid-0.1.0.tgz","fileCount":7,"integrity":"sha512-2NjYWCY0yixQ7lKfy2ccUonKo6gVs76e04RYf0aW4NNXNAsRmLIbnSpe0seT/7ZKBnuiaELfNIeZWSAxrsqL7g==","signatures":[{"sig":"MEUCIANTNlHmKDhvV9pNlAPT2CgtkhcfTuw94OXbRLZA2LJEAiEApBq+KNSdNFlJ2/DzdHEqUiJNGGEIHykj6pw/mMJLs1s=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":6445,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgtoNgCRA9TVsSAnZWagAAO7sQAKFQloUgK4xWzIDxp1T2\nzN65OOJxvInkAzv+Ewy41Fe14oVhmzrFREja56cO3OWMuF/Xxb9ZJyShtzfZ\nnw2ZUPn3H0R+7VsXFaIgdLQlCs5i1RzIEp92m/j8CXJMpDTTYh2bG/ihPzTs\n2Z4yndeV3XG4ET/6kKrnGTEK0roQHKvEbWjKAE2HhvR3Czc+fJ1jqfWaCOU6\n+so2Pev1iuh2W8dLvk90aZ/wmzPxcckUcw/hoCIk6oSNuHGxevgYAf8DqsUh\nI75c/9PpgQzWjsH3q+2hiMOy++SrbcjfBmdyUo6h4VJGV3WABzBYQKu+6jUd\nfI9JkCnJs9dCzHAgzlsV++tbJAxawprtU8wXeQ/HIFwxSj9CVrhWRLEuanvK\nugiz2taADESKDIiB3xxM2e//GJy7jP8zXw0UOw75Ngj2T/uLrwv/3dAKPv9d\nd33zmE35lcQpBq1jwu6EmXfxsA5gyodSo0zxHSdUJXhSnmr6DRJluOefi4PZ\nncbnu5Qc2JnKdQRYlrYnRt8kufMY2a+AXUSKG1wJwl0A4AQgUaKR0gJ+FNu4\nGQo3ARX+Ru0nCjhP9Ci6KalLb8ArgZXKydIPxl8J+af9e1pmFOp71itrBG5Y\nPpO7l0IMBS8qF10Dj0ZDbYP38eZwZXolXNRAcZdN86VtsVFtc0XNlL5rIi9+\n5Lrl\r\n=rmns\r\n-----END PGP SIGNATURE-----\r\n"},"main":"build/index.js","gitHead":"6e62fe7bbeeab5b5d0f915226b0021788e6850ce","scripts":{"test":"jest","build":"tsc"},"_npmUser":{"name":"basementuniverse","email":"gordonlarrigan@gmail.com"},"repository":{"url":"git+https://github.com/basementuniverse/shortuid.git","type":"git"},"_npmVersion":"6.14.12","description":"Generate short unique IDs","directories":{},"_nodeVersion":"12.22.1","dependencies":{"dotenv-flow":"^3.2.0","bignumber.js":"^9.0.1"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^27.0.1","ts-jest":"^27.0.1","typescript":"^4.3.2","@types/jest":"^26.0.23","@types/dotenv-flow":"^3.1.0"},"_npmOperationalInternal":{"tmp":"tmp/shortuid_0.1.0_1622573919836_0.2745889647262574","host":"s3://npm-registry-packages"}},"1.0.0":{"name":"@basementuniverse/shortuid","version":"1.0.0","keywords":["short","id","uid","unique"],"author":{"url":"https://gordonlarrigan.com","name":"Gordon Larrigan","email":"gordonlarrigan@gmail.com"},"license":"MIT","_id":"@basementuniverse/shortuid@1.0.0","maintainers":[{"name":"basementuniverse","email":"gordonlarrigan@gmail.com"}],"homepage":"https://github.com/basementuniverse/shortuid#readme","bugs":{"url":"https://github.com/basementuniverse/shortuid/issues"},"dist":{"shasum":"c3889f32a4048a11fb0737ccd57af05320f5e7ef","tarball":"https://registry.npmjs.org/@basementuniverse/shortuid/-/shortuid-1.0.0.tgz","fileCount":6,"integrity":"sha512-wjl9LHUDwvU7AtwbWU6HgbBYDVDarIEcUIQ1c6vCUQTnhvknTaFvx5JK2G7H6cg4gLlkPAfq70SBTq0V1Zfx/Q==","signatures":[{"sig":"MEYCIQCzgTJRtvcI2iaC2KhImBwFvl8MFvuOY8ZSCBZhBT4M+wIhALm8tUXd6CqNj7Q/RvBaiyiptRT7ad0y21GsAWP5sHsi","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":6576},"main":"build/index.js","types":"./build/index.d.ts","gitHead":"bebb9d57f9508b3777682ca11f0259bebac28c1b","scripts":{"test":"jest","build":"tsc"},"_npmUser":{"name":"basementuniverse","email":"gordonlarrigan@gmail.com"},"repository":{"url":"git+https://github.com/basementuniverse/shortuid.git","type":"git"},"_npmVersion":"9.5.1","description":"Generate short unique IDs","directories":{},"_nodeVersion":"18.16.0","dependencies":{"bignumber.js":"^9.0.1"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^27.0.1","ts-jest":"^27.0.1","typescript":"^4.3.2","@types/jest":"^26.0.23"},"_npmOperationalInternal":{"tmp":"tmp/shortuid_1.0.0_1699056409666_0.5800206371124228","host":"s3://npm-registry-packages"}},"1.1.0":{"name":"@basementuniverse/shortuid","version":"1.1.0","description":"Generate short unique IDs","main":"build/index.js","scripts":{"build":"tsc","test":"jest"},"keywords":["short","id","uid","unique"],"author":{"name":"Gordon Larrigan","email":"gordonlarrigan@gmail.com","url":"https://gordonlarrigan.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/basementuniverse/shortuid.git"},"devDependencies":{"@types/jest":"^26.0.23","bloom-filters":"^3.0.4","jest":"^27.0.1","ts-jest":"^27.0.1","typescript":"^4.3.2"},"dependencies":{"bignumber.js":"^9.0.1"},"types":"./build/index.d.ts","gitHead":"09ffe4f45578e9e7446a890c081e7a2ab13942f5","bugs":{"url":"https://github.com/basementuniverse/shortuid/issues"},"homepage":"https://github.com/basementuniverse/shortuid#readme","_id":"@basementuniverse/shortuid@1.1.0","_nodeVersion":"18.17.1","_npmVersion":"9.6.7","dist":{"integrity":"sha512-Gmb9MdEgRHygzz+Au0MUYiuVbbsWpiOV0Fq58n3FXYpbe716U7BWKoEmcI5alWdyedxLiReG5GT45u2Qy2NcTg==","shasum":"73c709ca3f8862713f9c3c7c03ccd10286748feb","tarball":"https://registry.npmjs.org/@basementuniverse/shortuid/-/shortuid-1.1.0.tgz","fileCount":9,"unpackedSize":11058,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCuZDZNPpx0Vztrj0qi+4TevO4GSNJTU+EZKMHolhM4nQIhAIZVw9CnBQOGg1LJVS++UMabYkAZTqfJ4nOj9qxPIDFQ"}]},"_npmUser":{"name":"basementuniverse","email":"gordonlarrigan@gmail.com"},"directories":{},"maintainers":[{"name":"basementuniverse","email":"gordonlarrigan@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/shortuid_1.1.0_1732653522022_0.10145795346425412"},"_hasShrinkwrap":false}},"time":{"created":"2021-06-01T18:58:39.785Z","modified":"2024-11-26T20:38:42.397Z","0.1.0":"2021-06-01T18:58:39.950Z","1.0.0":"2023-11-04T00:06:49.836Z","1.1.0":"2024-11-26T20:38:42.221Z"},"bugs":{"url":"https://github.com/basementuniverse/shortuid/issues"},"author":{"name":"Gordon Larrigan","email":"gordonlarrigan@gmail.com","url":"https://gordonlarrigan.com"},"license":"MIT","homepage":"https://github.com/basementuniverse/shortuid#readme","keywords":["short","id","uid","unique"],"repository":{"type":"git","url":"git+https://github.com/basementuniverse/shortuid.git"},"description":"Generate short unique IDs","maintainers":[{"name":"basementuniverse","email":"gordonlarrigan@gmail.com"}],"readme":"# Short UID\n\nGenerate short unique IDs from sequential numbers.\n\nThe short unique IDs can be converted back to the original sequential numbers.\n\nThis can be useful when you have an auto-increment ID column in your database, but you want to show a short alpha-numeric ID to users.\n\nWith this package you can convert sequential numbers to random-looking ID strings and back again.\n\n## Installation\n\n```\nnpm install -g @basementuniverse/shortuid\n```\n\n## Usage\n\n```typescript\nimport Shortuid, { ShortuidOptions } from '@basementuniverse/shortuid';\n\nconst options: ShortuidOptions = {\n  // This should be a large prime number, coprime to base\n  // Try using https://primes.utm.edu/curios/index.php to find a suitable prime\n  prime: '6345796823',\n\n  // This should be a large integer\n  // It will define the size of the input domain, i.e. any inputs larger than base will result in duplicate ids\n  // Try using https://codinglab.huostravelblog.com/math/coprime-finder/index.php to find coprimes of prime\n  base: '10212011',\n\n  // The multiplicative modular inverse of prime modulo base\n  // Try using https://planetcalc.com/3311/ to find this value\n  inverse: '3736125',\n\n  // A large random number used to mix the output and add more entropy\n  // It must be larger than base\n  mixer: '28737113',\n\n  // A string containing all the characters that you want to see in the output\n  // Try using shuffled alphanumeric characters to add more entropy\n  // You may also wish to remove some hard-to-distinguish characters ('i', 'l', '1', '0', 'o' etc.)\n  alpha: '568vhgxrwkfjyn9d3pc2mqbaz74set',\n};\n\nconst numericId = 1;\nconst encodedShortId = Shortuid.encode(numericId, options);\n// encodedShortId will be a short id string, similar to 'f85k8'\n\nconst decodedNumericId = Shortuid.decode(encodedShortId, options);\nconsole.assert(decodedNumericId === numericId);\n```\n\nSome helper scripts are provided which might be useful for generating options:\n\n```bash\ncd helpers\n\n# Generate prime, base, inverse and mixer:\nnode generate-options.js\n\n# Generate a random alphabet:\nnode generate-alphabet.js\n\n# Check for collisions:\nnode check-collisions.js\n```\n","readmeFilename":"README.md"}