Ensure _.find and _.findLast pass "Collections" tests for the compat build.

This commit is contained in:
John-David Dalton
2014-03-15 02:41:37 -07:00
parent 95976814f5
commit 819fa88eb7

View File

@@ -3797,7 +3797,9 @@
* // => { 'name': 'fred', 'age': 40, 'blocked': true }
*/
function find(collection, predicate, thisArg) {
if (isArray(collection)) {
var length = collection ? collection.length : 0;
if (typeof length == 'number' && length > -1 && length <= maxSafeInteger) {
var index = findIndex(collection, predicate, thisArg);
return index > -1 ? collection[index] : undefined;
}
@@ -3826,7 +3828,9 @@
* // => 3
*/
function findLast(collection, predicate, thisArg) {
if (isArray(collection)) {
var length = collection ? collection.length : 0;
if (typeof length == 'number' && length > -1 && length <= maxSafeInteger) {
var index = findLastIndex(collection, predicate, thisArg);
return index > -1 ? collection[index] : undefined;
}