UNPKG

411 BJavaScriptView Raw
1import { bindCallback } from '../util/bindcallback';
2export function find(source, predicate, thisArg) {
3 if (typeof predicate !== 'function') {
4 throw new TypeError();
5 }
6 const f = bindCallback(predicate, thisArg, 2);
7 let i = 0;
8 for (const item of source) {
9 if (f(item, i++)) {
10 return item;
11 }
12 }
13 return undefined;
14}
15
16//# sourceMappingURL=find.mjs.map