UNPKG

411 BJavaScriptView Raw
1import { bindCallback } from '../util/bindcallback';
2export function findIndex(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 i;
11 }
12 }
13 return -1;
14}
15
16//# sourceMappingURL=findindex.mjs.map