Skip to content

Create fast and unique IDs with 227 byte πŸ€™πŸ»

Notifications You must be signed in to change notification settings

fers4t/kgid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

kgid

Fastest unique id generator.

Installation

pnpm i kgid

Usage

import { kgid } from 'kgid';

console.log(kgid());

Benchmarking

➜  benchmark> node index.mjs
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ (index) β”‚  Task Name   β”‚  Average Time (ps)  β”‚     Variance (ps)     β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚    0    β”‚   'nanoid'   β”‚ 0.21404910435571142 β”‚ 0.0010931945194185824 β”‚
β”‚    1    β”‚    'kgid'    β”‚ 0.08688025856545194 β”‚ 0.0002604025737242756 β”‚
β”‚    2    β”‚ 'react-uuid' β”‚ 0.7893323068767657  β”‚  0.02007272352994441  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
kgid x 26,559,754 ops/sec Β±0.31% (97 runs sampled)
react-uuid x 1,408,511 ops/sec Β±0.18% (98 runs sampled)
nanoid() x 6,048,306 ops/sec Β±0.69% (95 runs sampled)
Fastest is kgid
➜  benchmark> node unique-test.mjs
1000000 times kgid: All generated ids are unique
1000000 times nanoid: All generated ids are unique
1000000 times react-uuid: All generated ids are unique