UNPKG

676 BJavaScriptView Raw
1import isFunction from './is-function';
2import isMatch from './is-match';
3import isArray from './is-array';
4import isPlainObject from './is-plain-object';
5function find(arr, predicate) {
6 if (!isArray(arr))
7 return null;
8 var _predicate;
9 if (isFunction(predicate)) {
10 _predicate = predicate;
11 }
12 if (isPlainObject(predicate)) {
13 _predicate = function (a) { return isMatch(a, predicate); };
14 }
15 if (_predicate) {
16 for (var i = 0; i < arr.length; i += 1) {
17 if (_predicate(arr[i])) {
18 return arr[i];
19 }
20 }
21 }
22 return null;
23}
24export default find;
25//# sourceMappingURL=find.js.map
\No newline at end of file