Example #1
0
module.exports = function (options) {

  options = options || {
      sentences: randomNatural({
        min: 3,
        max: 7,
        inspected: true
      })
    };

  var length = options.sentences;

  if (!length && (options.min || options.max)) {
    length = randomNatural({
      min: options.min || MIN_LEN,
      max: options.max || MAX_LEN
    });
  }

  length = length || randomNatural({
      min: MIN_LEN,
      max: MAX_LEN,
      inspected: true
    });

  length = clamp(length, MIN_LEN, MAX_LEN);

  var sentences = [];

  while (length--) {
    sentences.push(randomSentence());
  }

  return sentences.join(' ');
};
Example #2
0
module.exports = function (options) {

  options = options || {};

  var length = options.length;

  if (length) {
    length = toLength(options.length);
  }

  if (!length) {

    if (options.min || options.max) {
      length = randomNatural(options);
    } else {
      length = randomNatural({ min: 5, max: 20, inspected: true });
    }
  }

  var result = '';

  while (length--) {
    result += randomChar(options);
  }

  return result;
};
Example #3
0
module.exports = function (options) {

  // unicode range: http://billposer.org/Linguistics/Computation/UnicodeRanges.html

  if (options) {
    options.min = fixme(options.min);
    options.max = fixme(options.max);
  } else {
    options = {
      min: 0,
      max: MAX
    };
  }

  options.min = clamp(options.min, 0, MAX);
  options.max = clamp(options.max, 0, MAX);

  options.inspected = true;

  var int = randomNatural(options);
  var hex = int.toString(16);

  hex = padStart(hex, 4, 0);

  return '\\u' + toUpper(hex);
};
Example #4
0
module.exports = function (thrown, options) {

  options = options || {};

  if (!thrown) {
    throw new RangeError('A type of die roll must be included');
  } else {

    var bits = thrown.toLowerCase().split('d');
    if (bits.length !== 2 || !parseInt(bits[0], 10) || !parseInt(bits[1], 10)) {
      throw new Error('Invalid format provided. Please provide #d# where the first # is the number of dice to roll, the second # is the max of each die');
    }

    var rolls = [];

    for (var i = bits[0]; i > 0; i--) {
      rolls[i - 1] = randomNatural({
        min: 1,
        max: bits[1]
      });
    }

    return options.sum
      ? rolls.reduce(function (p, c) { return p + c; })
      : rolls;
  }
};
Example #5
0
module.exports = function (options) {

  options = options || {
      syllables: randomNatural({
        min: 1,
        max: 3,
        inspected: true
      })
    };

  var length    = options.length;
  var syllables = options.syllables;

  var result = '';

  if (syllables) {
    for (var i = 0; i < syllables; i++) {
      result += randomSyllable();
    }

    return result.substring(0, MAX_LEN);
  }


  if (!length && ( options.min || options.max)) {
    length = randomNatural({
      min: options.min || MIN_LEN,
      max: options.max || MAX_LEN
    });
  }

  length = length || randomNatural({
      min: MIN_LEN,
      max: MAX_LEN,
      inspected: true
    });


  length = clamp(length, MIN_LEN, MAX_LEN);


  while (result.length < length) {
    result += randomSyllable();
  }

  return result.substring(0, length);
};
Example #6
0
module.exports = function (options) {

  var i = 5;

  var result = '';

  while (i--) {
    result += randomNatural({ min: 0, max: 9, inspected: true }).toString();
  }

  if (options && options.plusfour) {

    result += '-';

    i = 4;
    while (i--) {
      result += randomNatural({ min: 0, max: 9, inspected: true }).toString();
    }
  }

  return result;
};
Example #7
0
module.exports = function (options) {

  if (options) {
    options.min = options.min ? randomNatural.fixme(options.min, MIN, MAX, true) : MIN;
    options.max = options.max ? randomNatural.fixme(options.max, MIN, MAX, false) : MAX;

    options = {
      min: options.min,
      max: options.max
    };
  } else {
    options = { min: MIN, max: MAX };
  }

  options.inspected = true;

  return randomNatural(options);
};
Example #8
0
module.exports = function (options) {

  var length = isObject(options)
    ? options.length
    : options;

  if (length) {
    length = toInteger(length);
    length = clamp(length, 2, 3);
  } else {
    length = randomNatural({ min: 2, max: 3 });
  }

  var consonants = 'bcdfghjklmnprstvwz'; // consonants except hard to speak ones
  var vowels = 'aeiou';                  // vowels
  var all = consonants + vowels;         // all

  var text = '';
  var char;

  for (var i = 0; i < length; i++) {
    if (i === 0) {
      // First character can be anything
      char = randomChar({ pool: all });
    } else if (consonants.indexOf(char) === -1) {
      // Last character was a vowel, now we want a consonant
      char = randomChar({ pool: consonants });
    } else {
      // Last character was a consonant, now we want a vowel
      char = randomChar({ pool: vowels });
    }

    text += char;
  }

  return text;
};
Example #9
0
module.exports = function (options) {
  var int   = randomNatural(options);
  var octal = int.toString(16);

  return '0x' + octal;
};