Skip to content

A random name generator as seen on Reddit, Heroku, Xbox, etc.

License

Notifications You must be signed in to change notification settings

aflansburg/spicy-donkey

Repository files navigation

npm version CI status

Spicy Donkey

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

Installation

npm install spicy-donkey

Usage

CommonJS (require)

const { generateRandomCombination } = require('spicy-donkey');

const name = generateRandomCombination('humorous', 'animal');
console.log(name); // Outputs a random combination e.g. "Spicy Donkey"

ES6 Module (import)

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"

Use it in the browser

<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.

How It Works

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.

Example output

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

Building Locally

To build and run the project locally, follow these steps:

  1. Clone the repository:
git clone https://github.com/yourusername/spicy-donkey.git
cd spicy-donkey
  1. Install dependencies
npm install
  1. Build the project&
npm run build
  1. Run the demo script:
node demo/demo.js

Arguments

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"

Demo Script

The demo script demonstrates how to use the generateRandomCombination function. It generates and prints several random name combinations.

To run the demo script:

  1. Compile the TypeScript files:
npx tsc
  1. 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'));

Adding data

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.

Building for browser

This projects includes a script to build for the browser

npm build:browser

License

This project is licensed under the MIT License. See the LICENSE file for details.

Author

Abe Flansburg (@aflansburg)

About

A random name generator as seen on Reddit, Heroku, Xbox, etc.

Resources

License

Stars

Watchers

Forks

Packages

No packages published