* Creates a `_.find` or `_.findLast` function. * * @private * @param {Function} findIndexFunc The function to find the collection index. * @returns {Function} Returns the new find function.
(findIndexFunc)
| 5142 | * @returns {Function} Returns the new find function. |
| 5143 | */ |
| 5144 | function createFind(findIndexFunc) { |
| 5145 | return function(collection, predicate, fromIndex) { |
| 5146 | var iterable = Object(collection); |
| 5147 | if (!isArrayLike(collection)) { |
| 5148 | var iteratee = getIteratee(predicate, 3); |
| 5149 | collection = keys(collection); |
| 5150 | predicate = function(key) { return iteratee(iterable[key], key, iterable); }; |
| 5151 | } |
| 5152 | var index = findIndexFunc(collection, predicate, fromIndex); |
| 5153 | return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined; |
| 5154 | }; |
| 5155 | } |
| 5156 | |
| 5157 | /** |
| 5158 | * Creates a `_.flow` or `_.flowRight` function. |
no test coverage detected