mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 23:57:49 +00:00
Reduce baseExtremum.
This commit is contained in:
23
lodash.js
23
lodash.js
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user