mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-12 03:47:50 +00:00
Ensure _.find and _.findLast pass "Collections" tests for the compat build.
This commit is contained in:
@@ -3797,7 +3797,9 @@
|
|||||||
* // => { 'name': 'fred', 'age': 40, 'blocked': true }
|
* // => { 'name': 'fred', 'age': 40, 'blocked': true }
|
||||||
*/
|
*/
|
||||||
function find(collection, predicate, thisArg) {
|
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);
|
var index = findIndex(collection, predicate, thisArg);
|
||||||
return index > -1 ? collection[index] : undefined;
|
return index > -1 ? collection[index] : undefined;
|
||||||
}
|
}
|
||||||
@@ -3826,7 +3828,9 @@
|
|||||||
* // => 3
|
* // => 3
|
||||||
*/
|
*/
|
||||||
function findLast(collection, predicate, thisArg) {
|
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);
|
var index = findLastIndex(collection, predicate, thisArg);
|
||||||
return index > -1 ? collection[index] : undefined;
|
return index > -1 ? collection[index] : undefined;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user