12345678910111213141516171819202122232425 |
- import baseIteratee from './_baseIteratee.js';
- import isArrayLike from './isArrayLike.js';
- import keys from './keys.js';
- function createFind(findIndexFunc) {
- return function(collection, predicate, fromIndex) {
- var iterable = Object(collection);
- if (!isArrayLike(collection)) {
- var iteratee = baseIteratee(predicate, 3);
- collection = keys(collection);
- predicate = function(key) { return iteratee(iterable[key], key, iterable); };
- }
- var index = findIndexFunc(collection, predicate, fromIndex);
- return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
- };
- }
- export default createFind;
|