Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Name words are in dictionary order only. #62

Open
lonbinder opened this issue Jun 2, 2022 · 1 comment
Open

Name words are in dictionary order only. #62

lonbinder opened this issue Jun 2, 2022 · 1 comment

Comments

@lonbinder
Copy link

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!

@ShaneMcC
Copy link

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'
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants