UNPKG

351 BJavaScriptView Raw
1import { bindCallback } from '../util/bindcallback';
2export async function find(source, predicate, thisArg) {
3 const fn = bindCallback(predicate, thisArg, 2);
4 let i = 0;
5 for await (const item of source) {
6 if (await fn(item, i++)) {
7 return item;
8 }
9 }
10 return undefined;
11}
12
13//# sourceMappingURL=find.mjs.map