A random name generator as seen on Reddit, Heroku, Xbox, etc. This project generates random combinations of adjectives and nouns to create unique and fun names.
Give it a try here
npm install spicy-donkey
const { generateRandomCombination } = require('spicy-donkey');
const name = generateRandomCombination('humorous', 'animal');
console.log(name); // Outputs a random combination e.g. "Spicy Donkey"
import { generateRandomCombination, AdjectiveType, NounType } from 'spicy-donkey';
const name = generateRandomCombination('celestial' as AdjectiveType, 'star' as NounType);
console.log(name);// Outputs a random combination e.g. "Colossal Orion"
<script src="https://cdn.jsdelivr.net/npm/spicy-donkey@latest/dist/bundle.js"></script>
<script>
async function generateName() {
...
try {
const result = await SpicyDonkey.generateRandomCombination(adjectiveType, nounType);
...
} catch (error) {
console.error('Error generating name:', error);
...
}
}
</script>
- Note you'll need to store the
nouns
&adjectives
in a/data
folder accessible to your client application.
The generator uses predefined lists of adjectives and nouns stored in JSON files. It randomly selects one adjective and one noun to create a combination. The types of adjectives and nouns can be specified to generate different styles of names.
You can run npm run build && node demo/demo.js
to see the random output:
Comical TibetanMastiff
Observant Ford Explorer
Perceptive Dunnart
Bonkers Tesla Model S
Vibrant Homam
Ferocious Genesis GV80
Bursting Echidna
Nincompoopish Achird
Logical 41 Orionis
To build and run the project locally, follow these steps:
- Clone the repository:
git clone https://github.com/yourusername/spicy-donkey.git
cd spicy-donkey
- Install dependencies
npm install
- Build the project&
npm run build
- Run the demo script:
node demo/demo.js
The main function generateRandomCombination
accepts two arguments:
adjectiveType
: The type of adjective to use. Can be either'serious'
,'humorous'
, or'celestial'
.nounType
: The type of noun to use. Can be either'car'
,'animal'
,'star'
.
Example usage:
const name = generateRandomCombination('humorous', 'animal');
console.log(name); // Outputs a random combination like "Cheeky Monkey"
The demo script demonstrates how to use the generateRandomCombination
function. It generates and prints several random name combinations.
To run the demo script:
- Compile the TypeScript files:
npx tsc
- Run the demo script:
node demo/demo.js
The demo script will output random name combinations based on different adjective and noun types.
Example output:
console.log(generateRandomCombination('humorous', 'animal'));
console.log(generateRandomCombination('serious', 'car'));
console.log(generateRandomCombination('serious', 'animal'));
console.log(generateRandomCombination('humorous', 'car'));
Notice that noun json is all stored in files ending in the plural s
. For the time being, be sure that your noun set ends in s
.
This projects includes a script to build for the browser
npm build:browser
This project is licensed under the MIT License. See the LICENSE file for details.
Abe Flansburg (@aflansburg)