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