_baseRandom.js 541 B

12345678910111213141516171819
  1. /* Built-in method references for those with the same name as other `lodash` methods. */
  2. var nativeFloor = Math.floor,
  3. nativeRandom = Math.random;
  4. /**
  5. * The base implementation of `_.random` without support for returning
  6. * floating-point numbers.
  7. *
  8. * @private
  9. * @param {number} lower The lower bound.
  10. * @param {number} upper The upper bound.
  11. * @returns {number} Returns the random number.
  12. */
  13. function baseRandom(lower, upper) {
  14. return lower + nativeFloor(nativeRandom() * (upper - lower + 1));
  15. }
  16. module.exports = baseRandom;