* 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)
| 28246 | * @returns {Function} Returns the new find function. |
| 28247 | */ |
| 28248 | function createFind(findIndexFunc) { |
| 28249 | return function (collection, predicate, fromIndex) { |
| 28250 | var iterable = Object(collection); |
| 28251 | if (!isArrayLike(collection)) { |
| 28252 | var iteratee = baseIteratee(predicate, 3); |
| 28253 | collection = keys(collection); |
| 28254 | predicate = function predicate(key) { |
| 28255 | return iteratee(iterable[key], key, iterable); |
| 28256 | }; |
| 28257 | } |
| 28258 | var index = findIndexFunc(collection, predicate, fromIndex); |
| 28259 | return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined; |
| 28260 | }; |
| 28261 | } |
| 28262 | |
| 28263 | module.exports = createFind; |
| 28264 |
no test coverage detected