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