baseRandom.js 569 B

123456789101112131415161718
  1. /* Native 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 argument juggling
  6. * and returning floating-point numbers.
  7. *
  8. * @private
  9. * @param {number} min The minimum possible value.
  10. * @param {number} max The maximum possible value.
  11. * @returns {number} Returns the random number.
  12. */
  13. function baseRandom(min, max) {
  14. return min + nativeFloor(nativeRandom() * (max - min + 1));
  15. }
  16. module.exports = baseRandom;