1 | import baseIteratee from './_baseIteratee.js';
|
2 | import isArrayLike from './isArrayLike.js';
|
3 | import keys from './keys.js';
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | function createFind(findIndexFunc) {
|
13 | return function(collection, predicate, fromIndex) {
|
14 | var iterable = Object(collection);
|
15 | if (!isArrayLike(collection)) {
|
16 | var iteratee = baseIteratee(predicate, 3);
|
17 | collection = keys(collection);
|
18 | predicate = function(key) { return iteratee(iterable[key], key, iterable); };
|
19 | }
|
20 | var index = findIndexFunc(collection, predicate, fromIndex);
|
21 | return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
|
22 | };
|
23 | }
|
24 |
|
25 | export default createFind;
|