Mnemonic id
![npm type definitions](https://img.shields.io/npm/types/mnemonic-id)
Library to generate easy to remember, and sometimes entertaining, human readable ids.
createStoryId();
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:
import { createNameId } from 'mnemonic-id';
createNameId();
import * as mnemonicId from 'mnemonic-id';
mnemonicId.createNameId();
const mnemonicId = require('mnemonic-id');
mnemonicId.createNameId();
Then select one of the existing id formats:
createNounId();
createNameId();
createLongNameId();
createUniqueNameId();
createQuestId();
createStoryId();
createLongStoryId();
createNumberId(10);
createId(10);
Or customize your own:
createCustomId({
adjectives: 2,
subject: true,
verb: true,
object: true,
numberSuffix: 4,
idSuffix: 6,
delimiter: '_',
capitalize: true
});
Most existing formats can also be customized:
createNameId({
adjectives: 3,
capitalize: true
delimiter: '',
});
Options
Description of options:
interface IdOpts {
adjectives?: number;
subject?: boolean;
verb?: boolean;
object?: boolean;
numberSuffix?: number;
idSuffix?: number;
delimiter?: string;
capitalize?: boolean;
}
Alternatives
Similar libraries that also exist:
License
Licensed under MIT.