Ensure _.max and _.min return the correct value when callback computes +/-Infinity.

This commit is contained in:
John-David Dalton
2014-04-25 07:21:10 -07:00
parent 4c63be066f
commit 250ca36f05
2 changed files with 14 additions and 4 deletions

View File

@@ -4239,7 +4239,7 @@
baseEach(collection, function(value, index, collection) {
var current = callback(value, index, collection);
if (current > computed) {
if (current > computed || (current === -Infinity && current === result)) {
computed = current;
result = value;
}
@@ -4314,7 +4314,7 @@
baseEach(collection, function(value, index, collection) {
var current = callback(value, index, collection);
if (current < computed) {
if (current < computed || (current === Infinity && current === result)) {
computed = current;
result = value;
}