Implementing a globally unique ID generator with added entropy, stored in a 24-character case-sensitive string, utilizing UUID and base62 conversion for shorter IDs.
Leveraging Crypto.randomUUID in Node 19+ to generate IDs with extra entropy, achieving the ability to create 100,000 IDs in 340ms in a WSL environment, emphasizing server-side usage for performance.
The custom routine is implemented as an ESM module for server-side use due to broader support, with potential for client-side use post-transpilation, but limited browser support for Crypto.randomUUID.
Code usage involves simple functions: createUniqueId() for generating IDs and toBase62() for converting numbers to base62, with the latter adapted from base62.js for efficiency and enhanced with additional checks.
#id-generator #distributed-systems #base62-conversion #server-side-implementation #performance-optimization
Collection
[
|
...
]