Generator Class
A word generator utility
Patterns
A pattern describes how to generate words. It consists of a series of characters, each referencing a group. If the letter is uppercase, the result will also be in uppercase.
Example:
var generator = new Generator();
generator.pattern('Cvcvcv');
generator.generate(); // returns something like 'Tafenu'
Groups
Groups are simple arrays with characters.
Constructor
Generator
()
Methods
generate
(
String
-
[callback]
Generates a word using this instances pattern and groups.
Parameters:
-
[callback]
Callback (error, result) optionalnode-style callback with the word as second parameter
Returns:
String:
the word
generate
(
String
static
-
[callback]
generates a default-configured word, with optional callback
Parameters:
-
[callback]
Callback (error, result) optionalnode-style callback with word as second parameter
Returns:
String:
the word
group
(
Array Character
-
key
-
[value]
Gives the group for the key, or sets this group
Parameters:
-
key
Characterthe name of this group (one character, lowercase)
-
[value]
Array Character optionalthe new array of characters for this group
Returns:
Array Character:
the current group (in case of setting, the old group)
pattern
(
String
-
[pattern]
Gives the pattern, or sets it
Parameters:
-
[pattern]
String optionalthe pattern, see chapter in documentation for details
Returns:
String:
the current pattern (the old, if set)