1 var baseEach = require('./baseEach');
4 * Gets the extremum value of `collection` invoking `iteratee` for each value
5 * in `collection` to generate the criterion by which the value is ranked.
6 * The `iteratee` is invoked with three arguments: (value, index|key, collection).
9 * @param {Array|Object|string} collection The collection to iterate over.
10 * @param {Function} iteratee The function invoked per iteration.
11 * @param {Function} comparator The function used to compare values.
12 * @param {*} exValue The initial extremum value.
13 * @returns {*} Returns the extremum value.
15 function baseExtremum(collection, iteratee, comparator, exValue) {
16 var computed = exValue,
19 baseEach(collection, function(value, index, collection) {
20 var current = +iteratee(value, index, collection);
21 if (comparator(current, computed) || (current === exValue && current === result)) {
29 module.exports = baseExtremum;