unique-names-generator icon indicating copy to clipboard operation
unique-names-generator copied to clipboard

Name words are in dictionary order only.

Open lonbinder opened this issue 2 years ago • 1 comments

I just started using unique names generator, thank you for working on this! My code essentially is:

import { uniqueNamesGenerator, Config, adjectives, colors, animals, names, languages } from 'unique-names-generator';
...
    static NAME_CONFIG: Config = {
        dictionaries: [animals, adjectives, colors, names, languages],
        separator: ' ',
        length: 2,
        style: 'capital'
    };
...
name = uniqueNamesGenerator(GekModel.NAME_CONFIG);

I have generated >100 names, 100% of them are two words, where the first word is whichever dictionary is listed first in the config; and the second word is whichever dictionary is listed second in the config. In the code I've included that means they're all names like "Deer Old" or ""Raccoon Victorious". If I change the config to list dictionaries in the order of "[adjectives, colors, animals, names, languages]" then I only get names like "Flaky Black" or "Combative Beige".

I would expect that the names use all the dictionary words in random order. Is there a configuration option or parameter that I'm missing? Or is this a bug?

THanks!

lonbinder avatar Jun 02 '22 13:06 lonbinder

This is as designed I believe. It uses the dictionaries in order and that seems desirable so that you can always ensure you get for example a coloured-animal username by using [colors, animals]

If you wanted to just use all of them, then you could do something like:

const NAME_WORDS = [...animals, ...adjectives, ...colors, ...names, ...languages];
const NAME_CONFIG = {
    dictionaries: [NAME_WORDS, NAME_WORDS],
    separator: ' ',
    length: 2,
    style: 'capital'
};

ShaneMcC avatar Jul 26 '22 12:07 ShaneMcC