yet-another-name-generator
Version:
Yet Another Name Generator
18 lines • 792 B
JavaScript
import { adjectives, animals, professions } from './dictionary/index.js';
const getRandom = (limit) => Math.floor(Math.random() * limit);
export function generate({ the = false, titleize = false, separator } = {}) {
const prefix = the ? 'the ' : '';
const allWords = animals.concat(professions);
let stupidname = `${adjectives[getRandom(adjectives.length)]} ${allWords[getRandom(allWords.length)]}`.toLowerCase();
if (titleize) {
stupidname = stupidname.replace(/(?:^|\s|-)\S/g, c => c.toUpperCase());
}
if (typeof separator === 'string') {
stupidname = stupidname.split(' ').join(separator);
}
else if (!separator) {
stupidname = stupidname.split(' ').join('');
}
return prefix + stupidname;
}
//# sourceMappingURL=index.js.map