Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

_baseRandom.js 541B

123456789101112131415161718
  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;