A problem I ran into when making the [[PDW]] utilizing [[Surrogate Keys]] for records - I don't like ambiguous characters, and I don't like wasted space. I wound up leaving some ambiguous characters in place (e.g. `l` and `1`) for the sake of the one-liner piece of code. ```typescript export function makeSmallID(length = 4): SmallID { return Math.random().toString(36).slice(13 - length).padStart(length, "0") } ``` [[UUID]]s use [[Alternate Counting Bases|Hexidecimal]] and are therefore super long when written out: `50cd2c15-c37c-47f3-8d1a-f3269eb0bae6` The problem is most of the bytes used to encode that character string are not actually random. The The [[NanoID]] [[Coding Package Manager|NPM]] package lets you BYO alphabet. It also provides some great standard alphabets: | Set Name | Characters | | ------------ | --------------------------------------------------- | | nolookalikes | `346789ABCDEFGHJKLMNPQRTUVWXYabcdefghijkmnpqrtwxyz` | There's 49 characters there. **** # More ## Source - Self - https://github.com/ai/nanoid - https://github.com/CyberAP/nanoid-dictionary - https://zelark.github.io/nano-id-cc/ ## Related