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