1 | /**
|
2 | * Returns the index of the first element in the array that satisfies the provided testing function.
|
3 | * Otherwise, it returns -1, indicating that no element passed the test.
|
4 | *
|
5 | * @export
|
6 | * @template T The type of the elements in the source sequence.
|
7 | * @param {Iterable<T>} source An iterable sequence whose elements to apply the predicate to.
|
8 | * @param {FindOptions<T>} options The options for a predicate for filtering, thisArg for binding and AbortSignal for cancellation.
|
9 | * @returns {number} The index of the first element in the array that passes the test. Otherwise, -1.
|
10 | */
|
11 | export function findIndex(source, options) {
|
12 | const { ['thisArg']: thisArg, ['predicate']: predicate } = options;
|
13 | let i = 0;
|
14 | for (const item of source) {
|
15 | if (predicate.call(thisArg, item, i++)) {
|
16 | return i;
|
17 | }
|
18 | }
|
19 | return -1;
|
20 | }
|
21 |
|
22 | //# sourceMappingURL=findindex.mjs.map
|