Reduce baseExtremum.

This commit is contained in:
John-David Dalton
2015-10-09 12:58:10 -07:00
parent adaf6d7955
commit 59278a7a85

View File

@@ -624,28 +624,19 @@
* @returns {*} Returns the extremum value.
*/
function baseExtremum(array, iteratee, comparator) {
var computed,
result,
index = -1,
var index = -1,
length = array.length;
while (++index < length) {
var value = array[index],
current = iteratee(value);
if (current === current && current != null) {
computed = current;
result = value;
break;
}
}
while (++index < length) {
var value = array[index],
current = iteratee(value);
if (current != null && comparator(current, computed)) {
computed = current;
result = value;
if (current != null && (computed === undefined
? current === current
: comparator(current, computed)
)) {
var computed = current,
result = value;
}
}
return result;