mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 10:57:49 +00:00
Reduce createFind.
This commit is contained in:
15
lodash.js
15
lodash.js
@@ -4559,18 +4559,13 @@
|
|||||||
function createFind(findIndexFunc) {
|
function createFind(findIndexFunc) {
|
||||||
return function(collection, predicate, fromIndex) {
|
return function(collection, predicate, fromIndex) {
|
||||||
var iterable = Object(collection);
|
var iterable = Object(collection);
|
||||||
predicate = getIteratee(predicate, 3);
|
|
||||||
if (!isArrayLike(collection)) {
|
if (!isArrayLike(collection)) {
|
||||||
var props = keys(collection);
|
var iteratee = getIteratee(predicate, 3);
|
||||||
|
collection = keys(collection);
|
||||||
|
predicate = function(key) { return iteratee(iterable[key], key, iterable); };
|
||||||
}
|
}
|
||||||
var index = findIndexFunc(props || collection, function(value, key) {
|
var index = findIndexFunc(collection, predicate, fromIndex);
|
||||||
if (props) {
|
return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
|
||||||
key = value;
|
|
||||||
value = iterable[key];
|
|
||||||
}
|
|
||||||
return predicate(value, key, iterable);
|
|
||||||
}, fromIndex);
|
|
||||||
return index > -1 ? collection[props ? props[index] : index] : undefined;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user