You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
568 B

4 years ago
  1. var baseSum = require('./_baseSum');
  2. /** Used as references for various `Number` constants. */
  3. var NAN = 0 / 0;
  4. /**
  5. * The base implementation of `_.mean` and `_.meanBy` without support for
  6. * iteratee shorthands.
  7. *
  8. * @private
  9. * @param {Array} array The array to iterate over.
  10. * @param {Function} iteratee The function invoked per iteration.
  11. * @returns {number} Returns the mean.
  12. */
  13. function baseMean(array, iteratee) {
  14. var length = array == null ? 0 : array.length;
  15. return length ? (baseSum(array, iteratee) / length) : NAN;
  16. }
  17. module.exports = baseMean;