"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var seed_random_1 = __importDefault(require("seed-random"));
var adjectives_1 = require("./words/adjectives");
var animals_1 = require("./words/animals");
var colors_1 = require("./words/colors");
/**
* @Method: Returns a three-word passphrase with a separator string
* between each word - order is adjective-color-animal
* @param {string} [sep = ' '] - The separator charatcter
* @param {string} [prevent = ''] - a matching string used
* to prevent (very unlikely) duplicate results
* @returns {string}
*/
function phrase(sep, prevent, short) {
if (sep === void 0) { sep = ' '; }
if (prevent === void 0) { prevent = ''; }
if (short === void 0) { short = false; }
var result = "" + color() + sep + animal();
if (!short) {
result = "" + adjective() + sep + result;
}
if (result !== prevent) {
return String(result);
}
else {
return phrase(sep, prevent);
}
throw new Error('shut up, compiler');
}
exports.phrase = phrase;
function setSeed(seedString) {
seed_random_1.default(seedString, { global: true });
}
exports.setSeed = setSeed;
function resetSeed() {
seed_random_1.default.resetGlobal();
}
exports.resetSeed = resetSeed;
/**
* @Method: Returns a random adjective from the words list.
* @returns {string}
*/
var adjective = function () {
return adjectives_1.adjectives[random(adjectives_1.adjectives.length)];
};
/**
* @Method: Returns a random color from the words list.
* @returns {string}
*/
var color = function () {
return colors_1.colors[random(colors_1.colors.length)];
};
/**
* @Method: Returns a random animal from the words list.
* @returns {string}
*/
var animal = function () {
return animals_1.animals[random(animals_1.animals.length)];
};
/**
* @Method: Returns a random number between 0 and max
* @returns {number}
*/
var random = function (max) {
Iif (max === void 0) { max = 1; }
return Math.floor(Math.random() * max);
};
//# sourceMappingURL=FriendlyPhrase.js.map |