2 * The base implementation of methods like `_.max` and `_.min` which accepts a
3 * `comparator` to determine the extremum value.
6 * @param {Array} array The array to iterate over.
7 * @param {Function} iteratee The iteratee invoked per iteration.
8 * @param {Function} comparator The comparator used to compare values.
9 * @returns {*} Returns the extremum value.
11 function baseExtremum(array, iteratee, comparator) {
13 length = array.length;
15 while (++index < length) {
16 var value = array[index],
17 current = iteratee(value);
19 if (current != null && (computed === undefined
21 : comparator(current, computed)
23 var computed = current,
30 module.exports = baseExtremum;