1.0.0 • Published 7 years ago

sirrobert-name-tokens v1.0.0

Weekly downloads
3
License
MIT
Repository
bitbucket
Last release
7 years ago

Overview

A module for generating human-readable name tokens automatically.

Usage

Installation

Install locally or globally.

npm install [--global] sirrobert-name-tokens

Invocation

The module has a node interface as well as a command-line interface.

Command Line

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

Programming Interface

const Name = require("sirrobert-name-tokens");

Create a name

var name = Name.generate();

Create a name with a custom words list.

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]+/).

Custom Delimiters

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.

TO DO

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.

A note on the module namespace (sirrobert-)

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