{"_id":"hexoid","_rev":"4244977","name":"hexoid","description":"A tiny (190B) and extremely fast utility to generate random IDs of fixed length","dist-tags":{"latest":"2.0.0"},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"time":{"modified":"2026-03-29T21:29:11.000Z","created":"2020-03-03T05:40:15.006Z","2.0.0":"2024-10-12T08:48:08.718Z","1.0.0":"2020-03-10T06:59:27.688Z","0.0.0":"2020-03-03T05:40:15.006Z"},"users":{},"author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"https://lukeed.com"},"repository":{"type":"git","url":"git+https://github.com/lukeed/hexoid.git"},"versions":{"2.0.0":{"name":"hexoid","version":"2.0.0","repository":{"type":"git","url":"git+https://github.com/lukeed/hexoid.git"},"description":"A tiny (190B) and extremely fast utility to generate random IDs of fixed length","module":"dist/index.mjs","types":"dist/index.d.ts","main":"dist/index.js","license":"MIT","author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"https://lukeed.com"},"engines":{"node":">=8"},"scripts":{"build":"node bin/build","test":"uvu test -r esm -i collisions"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"},"./package.json":"./package.json"},"keywords":["id","uid","uuid","random","generate"],"devDependencies":{"esm":"3.2.25","terser":"4.8.0","uvu":"0.5.3"},"_id":"hexoid@2.0.0","gitHead":"a23cb66b42595b3c6c443ca2bbea9aac50504cc9","bugs":{"url":"https://github.com/lukeed/hexoid/issues"},"homepage":"https://github.com/lukeed/hexoid#readme","_nodeVersion":"20.10.0","_npmVersion":"10.2.3","dist":{"shasum":"fb36c740ebbf364403fa1ec0c7efd268460ec5b9","size":3300,"noattachment":false,"key":"/hexoid/-/hexoid-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/hexoid/download/hexoid-2.0.0.tgz"},"_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"directories":{},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hexoid_2.0.0_1728722888508_0.22115292778774265"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-10-12T08:48:08.718Z","publish_time":1728722888718,"_source_registry_name":"default","_cnpm_publish_time":1728722888718},"1.0.0":{"name":"hexoid","version":"1.0.0","repository":{"type":"git","url":"git+https://github.com/lukeed/hexoid.git"},"description":"A tiny (190B) and extremely fast utility to generate random IDs of fixed length","unpkg":"dist/index.min.js","module":"dist/index.mjs","main":"dist/index.js","types":"hexoid.d.ts","license":"MIT","author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"https://lukeed.com"},"engines":{"node":">=8"},"scripts":{"build":"bundt","pretest":"npm run build","test":"tape -r esm test/*.js | tap-spec"},"keywords":["id","uid","uuid","random","generate"],"devDependencies":{"bundt":"1.0.0","esm":"3.2.25","tap-spec":"5.0.0","tape":"4.9.1"},"gitHead":"a559503e2f8886060a6972975a9c34a49dcd46b2","bugs":{"url":"https://github.com/lukeed/hexoid/issues"},"homepage":"https://github.com/lukeed/hexoid#readme","_id":"hexoid@1.0.0","_npmVersion":"6.4.1","_nodeVersion":"10.13.0","_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"dist":{"shasum":"ad10c6573fb907de23d9ec63a711267d9dc9bc18","size":3538,"noattachment":false,"key":"/hexoid/-/hexoid-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/hexoid/download/hexoid-1.0.0.tgz"},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hexoid_1.0.0_1583823567474_0.11775983696085879"},"_hasShrinkwrap":false,"publish_time":1583823567688,"_cnpm_publish_time":1583823567688},"0.0.0":{"name":"hexoid","version":"0.0.0","repository":{"type":"git","url":"git+https://github.com/lukeed/hexoid.git"},"description":"WIP","unpkg":"dist/index.min.js","module":"dist/index.mjs","main":"dist/index.js","types":"foid.d.ts","license":"MIT","author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"https://lukeed.com"},"engines":{"node":">=8"},"scripts":{"build":"bundt","pretest":"npm run build","test":"tape -r esm test/*.js | tap-spec"},"keywords":[],"devDependencies":{"bundt":"1.0.0","esm":"3.2.25","tap-spec":"5.0.0","tape":"4.9.1"},"gitHead":"a79c327d82dff81e303b2e96b9c1765361239fb5","bugs":{"url":"https://github.com/lukeed/hexoid/issues"},"homepage":"https://github.com/lukeed/hexoid#readme","_id":"hexoid@0.0.0","_npmVersion":"6.4.1","_nodeVersion":"10.13.0","_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"dist":{"shasum":"e7409c8e86198e94406c5da84acca2d24820725a","size":1165,"noattachment":false,"key":"/hexoid/-/hexoid-0.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/hexoid/download/hexoid-0.0.0.tgz"},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hexoid_0.0.0_1583214014843_0.294624000153179"},"_hasShrinkwrap":false,"publish_time":1583214015006,"_cnpm_publish_time":1583214015006}},"readme":"# hexoid [![CI](https://github.com/lukeed/hexoid/workflows/CI/badge.svg)](https://github.com/lukeed/hexoid/actions) [![licenses](https://licenses.dev/b/npm/hexoid)](https://licenses.dev/npm/hexoid) [![codecov](https://badgen.now.sh/codecov/c/github/lukeed/hexoid)](https://codecov.io/gh/lukeed/hexoid)\n\n> A tiny (190B) and [extremely fast](#benchmarks) utility to generate random IDs of fixed length\n\n_**Hexadecimal object IDs.** Available for Node.js and the browser._<br>Generate randomized output strings of fixed length using lowercased hexadecimal pairs.\n\n> **Notice:** Please note that this is not a cryptographically secure (CSPRNG) generator.\n\nAdditionally, this module is delivered as:\n\n* **CommonJS**: [`dist/index.js`](https://unpkg.com/hexoid/dist/index.js)\n* **ES Module**: [`dist/index.mjs`](https://unpkg.com/hexoid/dist/index.mjs)\n\n## Install\n\n```\n$ npm install --save hexoid\n```\n\n\n## Usage\n\n```js\nimport { hexoid } from 'hexoid';\n\nconst toID = hexoid();\n// length = 16 (default)\ntoID(); //=> '52032fedb951da00'\ntoID(); //=> '52032fedb951da01'\ntoID(); //=> '52032fedb951da02'\n\n// customize length\nhexoid(25)(); //=> '065359875047c63a037200e00'\nhexoid(32)(); //=> 'ca8e4aec7f139d94fcab9cab2eb89f00'\nhexoid(48)(); //=> 'c19a4deb5cdeca68534930e67bd0a2f4ed45988724d8d200'\n```\n\n\n## API\n\n### hexoid(length?)\nReturns: `() => string`\n\nCreates the function that will generate strings.\n\n#### length\nType: `Number`<br>\nDefault: `16`\n\nThen length of the output string.\n\n> **Important:** Your risk of collisions decreases with longer strings!<br>Please be aware of the [Birthday Problem](https://betterexplained.com/articles/understanding-the-birthday-paradox/)! You may need more combinations than you'd expect.\n\nThe **maximum combinations** are known given the following formula:\n\n```js\nconst combos = 256 ** (len/2);\n```\n\n\n## Benchmarks\n\n> Running on Node.js v10.13.0\n\n```\nValidation (length = 16):\n  ✔ hashids/fixed        (example: \"LkQWjnegYbwZ1p0G\")\n  ✔ nanoid/non-secure    (example: \"sLlVL5X3M5k2fo58\")\n  ✔ uid                  (example: \"3d0ckwcnjiuu91hj\")\n  ✔ hexoid               (example: \"de96b62e663ef300\")\nBenchmark (length = 16):\n  hashids/fixed        x     349,462 ops/sec ±0.28% (93 runs sampled)\n  nanoid/non-secure    x   3,337,573 ops/sec ±0.28% (96 runs sampled)\n  uid                  x   3,553,482 ops/sec ±0.51% (90 runs sampled)\n  hexoid               x  81,081,364 ops/sec ±0.18% (96 runs sampled)\n\n\nValidation (length = 25):\n  ✔ cuid                 (example: \"ck7lj5hbf00000v7c9gox6yfh\")\n  ✔ hashids/fixed        (example: \"r9JOyLkQWjnegYbwZ1p0GDXNm\")\n  ✔ nanoid/non-secure    (example: \"hI202PVPJQRNrP6o6z4pXz4m0\")\n  ✔ uid                  (example: \"9904e9w130buxaw7n8358mn2f\")\n  ✔ hexoid               (example: \"01dfab2c14e37768eb7605a00\")\nBenchmark (length = 25):\n  cuid                 x     161,636 ops/sec ±1.36% (89 runs sampled)\n  hashids/fixed        x     335,439 ops/sec ±2.40% (94 runs sampled)\n  nanoid/non-secure    x   2,254,073 ops/sec ±0.23% (96 runs sampled)\n  uid                  x   2,483,275 ops/sec ±0.38% (95 runs sampled)\n  hexoid               x  75,715,843 ops/sec ±0.27% (95 runs sampled)\n\n\nValidation (length = 36):\n  ✔ uuid/v1              (example: \"c3dc1ed0-629a-11ea-8bfb-8ffc49585f54\")\n  ✔ uuid/v4              (example: \"8c89f0ca-f01e-4c84-bd71-e645bab84552\")\n  ✔ hashids/fixed        (example: \"EVq3Pr9JOyLkQWjnegYbwZ1p0GDXNmRBlAxg\")\n  ✔ @lukeed/uuid         (example: \"069ad676-48f9-4452-b11d-f20c3872dc1f\")\n  ✔ nanoid/non-secure    (example: \"jAZjrcDmHH6P1rT9EFdCdHUpF440SjAKwb2A\")\n  ✔ uid                  (example: \"5mhi30lgy5d0glmuy81llelbzdko518ow1sx\")\n  ✔ hexoid               (example: \"615209331f0b4630acf69999ccfc95a23200\")\nBenchmark (length = 36):\n  uuid/v1              x   1,487,947 ops/sec ±0.18% (98 runs sampled)\n  uuid/v4              x     334,868 ops/sec ±1.08% (90 runs sampled)\n  @lukeed/uuid         x   6,352,445 ops/sec ±0.27% (91 runs sampled)\n  hashids/fixed        x     322,914 ops/sec ±0.27% (93 runs sampled)\n  nanoid/non-secure    x   1,592,708 ops/sec ±0.25% (91 runs sampled)\n  uid                  x   1,789,492 ops/sec ±0.29% (92 runs sampled)\n  hexoid               x  71,746,692 ops/sec ±0.29% (93 runs sampled)\n```\n\n## Related\n\n- [uid](https://github.com/lukeed/uid) - A smaller (134B) but slower variant of this module with a different API\n- [@lukeed/uuid](https://github.com/lukeed/uuid) - A tiny (230B), fast, and cryptographically secure UUID (V4) generator for Node and the browser\n\n\n## License\n\nMIT © [Luke Edwards](https://lukeed.com)\n","_attachments":{},"homepage":"https://github.com/lukeed/hexoid#readme","bugs":{"url":"https://github.com/lukeed/hexoid/issues"},"license":"MIT"}