andreasonny83 / unique-names-generator Goto Github PK
View Code? Open in Web Editor NEWGenerate unique and memorable name strings
Home Page: https://codesandbox.io/s/unique-names-generator-7fn9r
License: MIT License
Generate unique and memorable name strings
Home Page: https://codesandbox.io/s/unique-names-generator-7fn9r
License: MIT License
Please remove the word sexual
from adjectives dict, or if any other similar words can also be removed? Thanks.
The readme links to CONTRIBUTING.md but the file is missing.
The word generator uses the same seed for all the dictionaries:
This results in a low number of combinations when combining dictionaries. See this example with 2 dictionaries with 4 words each:
https://codesandbox.io/s/unique-names-generator-forked-sbxpo?file=/src/index.ts
const numbers = ["1", "2", "3", "4"];
const letters = ["A", "B", "C", "D"];
const config: Config = {
dictionaries: [numbers, letters],
separator: "-",
length: 2,
style: "capital",
seed: Math.random() * 4294967296
};
const randomString = uniqueNamesGenerator(config);
The only possible outputs are 1-A
, 2-B
, 3-C
, 4-D
.
This issue only affects users that provide a seed
parameter. The default behavior of using Math.random()
works fine, because a new random number is generated for each dictionary.
Hello, I am looking to use something like this for my project, but I am currently in the note-taking and mock-up phase, so it would be cool to have a website (e.g. hosted on GitHub pages in another repository) that lets me generate plenty of names for testing/fun.
I haven't looked into this project much, but I am assuming this is mostly trivial given the generator is written in typescript.
Thanks in advance!
hello friend, this looks like a wonderful library!
i was thinking i'd like to generate random nicknames as defaults for my users
i'd like to seed the name generator with the email address of the user -- so that if re-authentication ever occurred, the user would receive the same pseudorandomly generated name
i wonder how we could implement this?
cheers!
👋 chase
1.18.1
to 1.18.2
.This version is covered by your current version range and after updating it in your project the build failed.
prettier is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
would be nice to specify a dictionary of numbers with variable length, without having to create it ourselves as a custom dictionary
to create names such as DangerousSnake456
This use case arose in my implementation while i was using the package in a project.
Right now, dictionaries are not being used randomly, for example: if length is 2, and dictionaries are 3 (dic1, dic2, dic3). The package always used first 2 instead of picking any two randomly.
Here's i got around this,
const customDictionary = [[colors, animals], [adjectives, animals]]
const whichDictionary = Math.floor(Math.random() * 2);// 0 or 1, chose a combination, this could be generated randomly upto length and those many dictionaries can be chosen and used.
uniquename: uniqueNamesGenerator({
dictionaries: customDictionary[whichDictionary],
length: 2,
separator: "",
});
The following code taken from the NumberDictionary example with an added seed: 0
will return different 3 digits when run at different times. This means that, although the generator is stable within the same run, the NumberDictionary.generate
call introduces some kind of randomness that is not ruled by the seed:
const { uniqueNamesGenerator, NumberDictionary } = require('unique-names-generator');
const numberDictionary = NumberDictionary.generate({ min: 100, max: 999 });
const characterName = uniqueNamesGenerator({
dictionaries: [['Dangerous'], ['Snake'], numberDictionary],
length: 3,
separator: '',
style: 'capital',
seed: 0,
});
characterName
Copy and paste this code to a node
interactive session, then exit the session, enter again and run it again. The characterName is the same except for the numbers.
2.19.0
to 2.19.1
.This version is covered by your current version range and after updating it in your project the build failed.
@typescript-eslint/parser is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
The new version differs by 5 commits.
1c8f0df
chore: publish v2.19.1
4c12dac
fix(typescript-estree): ts returning wrong file with project references (#1575)
e9cf734
docs(eslint-plugin): fix typo in readme
10d86b1
docs(eslint-plugin): [no-dupe-class-members] fix typo (#1566)
4670aab
fix(eslint-plugin): [unbound-method] blacklist a few unbound natives (#1562)
See the full diff
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
Hello,
I am using your package with Ethereum addresses as a seed (with the 0x
prefix removed) and the dictionaries adjectives
and animals
. It appears that some adjectives and animals will never (or extremely rarely?) be used when calling uniqueNamesGenerator
with the address as a seed but others will be very often.
For instance, if I want to generate a vanity name (i.e. I want my name generated from the ETH address to contains whale
, see script below)
The expected outcome is that every time I run the vanity name generator, I get an {adjective}
+ Whale nickname, where {adjective} is one of the many adjectives in the dictionary.
But in reality, it will very often be the same adjective, here is a sample of 100 generated names that includes Whale
(each one was generated using a different ETH address):
InternalWhale
RemarkableWhale
InternalWhale
InternalWhale
InternalWhale
InternalWhale
InternalWhale
RemarkableWhale
InternalWhale
RemarkableWhale
DigitalWhale
RemarkableWhale
InternalWhale
RemarkableWhale
InternalWhale
DigitalWhale
InternalWhale
RemarkableWhale
InternalWhale
InternalWhale
RemarkableWhale
RemarkableWhale
InternalWhale
RemarkableWhale
DigitalWhale
InternalWhale
InternalWhale
InternalWhale
InternalWhale
RemarkableWhale
RemarkableWhale
InternalWhale
RemarkableWhale
DigitalWhale
RemarkableWhale
RemarkableWhale
DigitalWhale
DigitalWhale
RemarkableWhale
InternalWhale
InternalWhale
RemarkableWhale
InternalWhale
RemarkableWhale
RemarkableWhale
InternalWhale
RemarkableWhale
InternalWhale
RemarkableWhale
InternalWhale
InternalWhale
InternalWhale
RemarkableWhale
DigitalWhale
InternalWhale
InternalWhale
RemarkableWhale
RemarkableWhale
RemarkableWhale
InternalWhale
InternalWhale
RemarkableWhale
RemarkableWhale
InternalWhale
InternalWhale
InternalWhale
RemarkableWhale
RemarkableWhale
InternalWhale
InternalWhale
RemarkableWhale
RemarkableWhale
RemarkableWhale
InternalWhale
DigitalWhale
DigitalWhale
RemarkableWhale
RemarkableWhale
InternalWhale
InternalWhale
RemarkableWhale
RemarkableWhale
RemarkableWhale
RemarkableWhale
DigitalWhale
RemarkableWhale
RemarkableWhale
InternalWhale
RemarkableWhale
RemarkableWhale
RemarkableWhale
RemarkableWhale
RemarkableWhale
RemarkableWhale
RemarkableWhale
RemarkableWhale
InternalWhale
InternalWhale
RemarkableWhale
InternalWhale
I think there is an issue in how the seed is generated from a string, perhaps it is too big? Also, if tou try using a VERY big number as a seed, you will always end up with the same name, so I think there is an issue with the seed.
Script to generate vanity names:
const { uniqueNamesGenerator, adjectives, colors, animals } = require('unique-names-generator');
var Web3 = require('web3');
const arg = process.argv[2];
const web3 = new Web3();
if (!arg) {
const readline = require('readline').createInterface({
input: process.stdin,
output: process.stdout,
});
readline.question('Vanity name should include: ', (contains) => {
console.log(`Searching name with ${contains}!`);
readline.close();
generateVanityName(contains);
});
} else {
console.log(`Searching name with ${arg}!`);
generateVanityName(arg);
}
function generateNameFromAddress(address) {
const customConfig = {
dictionaries: [adjectives, animals],
separator: '',
length: 2,
seed: address,
style: 'capital',
};
return uniqueNamesGenerator(customConfig);
}
function generateVanityName(contains) {
let account;
let name;
do {
account = web3.eth.accounts.create();
name = generateNameFromAddress(account.address.replace('0x', ''));
} while (!name || !name.toLowerCase().includes(contains.toLowerCase()));
console.log(account);
console.log(name);
return;
}
Hi!
I would like to know whether you would consider a PR adding support for i18n?
With Below Code i got a result of availablesly moore625
which after inspection is a combination of available
and sly moore
and 625
where sly moore
has a space in between not truncated
let uniqueName = uniqueNamesGenerator({
dictionaries: [adjectives, starWars, numberDictionary],
length: 3,
separator: '',
style: 'lowerCase',
});
let exists = await this.workspaceModel.exists({
workspace_url: `${uniqueName}`,
});
while (!!exists) {
uniqueName = uniqueNamesGenerator({
dictionaries: [adjectives, starWars, numberDictionary],
length: 3,
separator: '',
style: 'lowerCase',
});
exists = await this.workspaceModel.exists({ workspace_url: uniqueName });
}
As a user, I should be able to pass my own dictionaries to get my preferred style of random names .
Example.
Following input should generate random names like "Brash_ProfessorX" , "Goldern_Wolverine" etc. i.e. formed out of combination of randomly selected values for each key in the input JSON
{
"ADJECTIVES":[
"Abrasive",
"Brash",
"Callous",
"Daft",
"Eccentric",
"Fiesty",
"Golden",
"Holy",
"Ignominious",
"Joltin",
"Killer",
"Luscious",
"Mushy",
"Nasty",
"OldSchool",
"Pompous",
"Quiet",
"Rowdy",
"Sneaky",
"Tawdry",
"Unique",
"Vivacious",
"Wicked",
"Xenophobic",
"Yawning",
"Zesty"
],
" XMEN":[
"ProfessorX",
"Beast",
"Colossus",
"Cyclops",
"Iceman",
"MarvelGirl",
"Storm",
"Wolverine",
"Shadowcat",
"Nightcrawler",
"Rogue",
"Angel",
"Dazzler",
"Syndicate",
"Magician",
"Bishop",
"Pyro",
"Psylocke",
"Toad",
"Firestar"
]
}
const seed1 = "0_1B:10_2B:12_3B:5_4B:5_ST:6"; const seed2 = "0_1B:10_2B:10_3B:6_4B:5_ST:7";
Hey!
Recently I noticed that if I passed these two different string to seed, the result would be same.
Here is my testing repo. Feel free to check it out.
Currently, I solved this issue by using stringToSeed
function, simply convert string to number, and the issue is gone. Yet I'm still curious about the reason of the coincidence shown above.
I couldn't find any option to have the first letter capital of the username.
Eg. "Big Donkey"
I'd be happy to contribute by implementing this feature.
The adjective dictionary sometimes contains ethnic adjectives such as "american", "jewish", "iraqi", etc. Is there a way to exclude all ethnic adjectives from the generator?
2.19.0
to 2.19.1
.This version is covered by your current version range and after updating it in your project the build failed.
@typescript-eslint/eslint-plugin is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
The new version differs by 5 commits.
1c8f0df
chore: publish v2.19.1
4c12dac
fix(typescript-estree): ts returning wrong file with project references (#1575)
e9cf734
docs(eslint-plugin): fix typo in readme
10d86b1
docs(eslint-plugin): [no-dupe-class-members] fix typo (#1566)
4670aab
fix(eslint-plugin): [unbound-method] blacklist a few unbound natives (#1562)
See the full diff
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
e.g. 481205670100679769679798 yields one thing but anything longer than this integer gives same result as 0
Ideally I'd like to give a string seed and get a unique name from the string, I was doing some string to int conversions but when they got too long they were all the exact same.
const customConfig = {
dictionaries: [adjectives, colors, animals],
length: 2,
separator: ' ',
style: 'capital',
seed: encoded
};
This looks like a nice project!
I browsed through the docs and the code but could not find anything that would ensure uniqueness of the generated names. Am I missing something?
This title says it all.
When I try to use this package to generate a unique username for a Next.js app with NextAuth running on Vercel's edge, it fails because it cannot import the crypto package.
Hi,
When creating random names, with combination of colors+adjactives+animals creates names likes red_grey_monkey etc. It would be nice if the adjective library does not contain colors or maybe some kind of filtering?
cheers!
Is there an option to get a unique name within 3 to 20 characters?
This is a good library, but the 'fucking' adjective is too far in my opinion and should be removed.
/lib/dictionaries/adjectives.ts line 903
I used the library to generate data for a quick mockup and it created "fucking_black_beaver" during a demonstration. It did not go down well.
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!
This snippet returns names capitalised, but colors and animals lowerCase:
const {
uniqueNamesGenerator,
colors,
animals,
names,
} = require("unique-names-generator");
const folderName = uniqueNamesGenerator({
dictionaries: [colors, animals, names],
separator: "-",
type: "lowerCase",
});
console.log(folderName);
Using version 4.4.0
Hi!
Using Create-React-App (latest version right now) with Typescript in a yarn workspace monorepo, importing and using this library resulted in the following error when trying to start the application for development:
[start:web ] i 「wds」: Project is running at http://<ip>/
[start:web ] i 「wds」: webpack output is served from /
[start:web ] i 「wds」: Content not from webpack is served from D:\Development\app\packages\web\public
[start:web ] i 「wds」: 404s will fallback to /index.html
[start:web ] Starting the development server...
[start:web ]
[start:web ] FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
[start:web ] 1: 00007FF76645F04A v8::internal::GCIdleTimeHandler::GCIdleTimeHandler+5114
[start:web ] 2: 00007FF76643A0C6 node::MakeCallback+4518
[start:web ] 3: 00007FF76643AA30 node_module_register+2032
[start:web ] 4: 00007FF7666C20EE v8::internal::FatalProcessOutOfMemory+846
[start:web ] 5: 00007FF7666C201F v8::internal::FatalProcessOutOfMemory+639
[start:web ] 6: 00007FF766BE2BC4 v8::internal::Heap::MaxHeapGrowingFactor+9556
[start:web ] 7: 00007FF766BD9C46 v8::internal::ScavengeJob::operator=+24310
[start:web ] 8: 00007FF766BD829C v8::internal::ScavengeJob::operator=+17740
[start:web ] 9: 00007FF766BE0F87 v8::internal::Heap::MaxHeapGrowingFactor+2327
[start:web ] 10: 00007FF766BE1006 v8::internal::Heap::MaxHeapGrowingFactor+2454
[start:web ] 11: 00007FF76679CDB7 v8::internal::Factory::NewFillerObject+55
[start:web ] 12: 00007FF766832CC6 v8::internal::WasmJs::Install+29414
[start:web ] 13: 000000D4B275C5C1
[start:web ] error Command failed with exit code 134.
[start:web ] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
[start:web ] error Command failed.
[start:web ] Exit code: 134
[start:web ] Command: C:\Program Files\nodejs\node.exe
[start:web ] Arguments: C:\Users\Maurice\AppData\Roaming\npm\node_modules\yarn\lib\cli.js start
[start:web ] Directory: D:\Development\app\packages\web
[start:web ] Output:
[start:web ]
[start:web ] info Visit https://yarnpkg.com/en/docs/cli/workspace for documentation about this command.
[start:web ] error Command failed with exit code 134.
[start:web ] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ERROR: "start:web" exited with 134.
When removing the code snippet below, the application started working again
const randomName = uniqueNamesGenerator({
length: 2,
separator: ' ',
style: 'capital',
dictionaries: [colors, animals]
});
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.