Reduce createFind.

This commit is contained in:
John-David Dalton
2016-05-23 16:06:16 -07:00
parent 02ff3e6258
commit 3fdac985c7

View File

@@ -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;
}; };
} }