Library for generating human-readable id strings.
const generateId = ;console;// ex. Regina's required requestconsole;// ex. Garrett's graceful giraffe
generateId function randomly pulls words from a default collection of nouns, adjectives, and names. To pull from a different set of words, you must use the
IdGenerator class and its
Using words in memory
IdGenerator constructor with instances of
const IdGenerator WordCollection = ;let nouns = 'chair' 'tie' 'lamp';let adjectives = 'good' 'bad' 'ugly';let names = 'Tom' 'Dick' 'Harry';let idGenerator = nouns adjectives names;console;// ex. Tom's ugly tie
Note that alliteration is not guaranteed if, for any word in the nouns collection, there isn't a word beginning with the same letter in both the adjectives and names collections, as above (
adjectives has no words beginning with 't').
Loading from files
IdGenerator.load to load words from text files. These files should contain words separated by newlines.
const IdGenerator = ;let idGenerator = IdGenerator;console;// ex. Leanna's logical laundry
WordCollection instances can also be loaded from files:
const IdGenerator WordCollection = ;let nouns = WordCollection;let adjectives = 'good' 'bad' 'ugly';let names = 'Tom' 'Dick' 'Harry';let idGenerator = nouns adjectives names;console;// ex. Harry's bad hair