Mnemonic id
Library to generate easy to remember, and sometimes entertaining, human readable ids.
createStoryId; // -> awesome-chipmunk-banish-evil-rat
Partly inspired by Docker name generator and major mnemonic system.
Highlights
- Dictionary of approximate 150 nouns (animals), 200 verbs, 500 adjectives.
- Deterministic id size, with max word length of 10 for nouns, 8 for verbs and adjectives.
- Customizable id generation.
- TypeScript annotated API.
- Slim package size with no dependencies.
Install
$ npm install mnemonic-id
Usage
Import in either way that suits your environment:
;createNameId;
;mnemonicId.createNameId;
;mnemonicId.createNameId;
Then select one of the existing id formats:
/** "noun", ≈ 10^2 permutations, 10 max length */createNounId; // -> narwhal /** "adj+noun", ≈ 10^5 permutations, 19 max length */createNameId; // -> hungry-hippo /** "adj+adj+noun", ≈ 10^6 permutations, 28 max length */createLongNameId; // -> hot-splendid-duck /** "adj+noun+id", ≈ 10^14 permutations, 26 max length */createUniqueNameId; // -> dull-dugong-QkCHmf /** "verb+adj+noun", ≈ 10^6 permutations, 28 max length */createQuestId; // -> find-pretty-sheep /** "adj+noun+verb+adj+noun", ≈ 10^12 permutations, 48 max length */createStoryId; // -> eloquent-beaver-quote-unknown-dinosaur /** "adj+adj+noun+verb+adj+adj+noun", ≈ 10^17 permutations, 64 max length */createLongStoryId; // -> wicked-evil-eel-help-horrible-pretty-hamster /** "number" of given length, length^10 - length^9 permutations */createNumberId10; // -> 6941634647 (= 10^10-10^9 permutations) /** "id" of given length, = 40^length permutations */createId10; // -> uXOGTUiOoD (= 40^10 ≈ 10^16 permutations)
Or customize your own:
createCustomId; // -> Talented_Bold_Pig_Hunt_Brawny_Supreme_Bumblebee_6343_VQ5EAZ
Most existing formats can also be customized:
createNameId; // -> OrdinaryCuddlyLaughingSquid
Options
Description of options:
Alternatives
Similar libraries that also exist:
License
Licensed under MIT.