A module for generating human-readable name tokens automatically.
Install locally or globally.
npm install [--global] sirrobert-name-tokens
The module has a node interface as well as a command-line interface.
You can install the binary (globally if you like):
npm install sirrobert-name-tokens
npm install sirrobert-name-tokens --global
Then you can generate names from the command line:
$> ./node_modules/sirrobert-name-token/bin/name
secret-station
const Name = require("sirrobert-name-tokens");
var name = Name.generate();
Name.loadWords('nouns' , './my-nouns-file.txt' );
Name.loadWords('adjectives' , './my-adjectives-file.txt' );
var name = Name.generate();
Word files are simple lists of words (not JSON). Here is an examples word file.
weird
welcome
west
western
wheel
while
white
whole
The list is split on whitespace using words = text.split(/[\s\r\n]+/)
.
By default the module uses '-' as a word delimiter. You can customize it by
setting Name.separator
like this:
const Name = require('sirrobert-name-tokens');
Name.generate(); // e.g. "munificent-twist"
Name.separator = '_'; // Change the separator to underscore.
Name.generate(); // e.g. "honest_monitor"
Name.separator = '@@@' // Change the separator to "@@@".
Name.generate(); // e.g. "obtuse@@@picture"
Separators are anything at all (they will be implicitly cast to strings). This includes using an empty string (""), which effectively concatenates the adjective and name.
I may want to add an option for allowing more variation by increasing the number of adjectives. For example, something like
Name.length = 1; // Use noun only.
Name.length = 2; // Default. A noun modified by a single adjective.
Name.length = 3; // A noun modified by two adjectives.
Name.length = 9; // A noun modified by eight adjectives.
The 'sirrobert-' module prefix is a staging namespace for my modules I am
testing with a small group of people. It will be moved to a general
namespace (for example, the sirrobert-
prefix removed).