1 | import { wrapWithAbort } from './operators/withabort';
|
2 | import { throwIfAborted } from '../aborterror';
|
3 | /**
|
4 | * Determines whether any element of an async-iterable sequence satisfies a condition.
|
5 | *
|
6 | * @export
|
7 | * @template T The type of the elements in the source sequence.
|
8 | * @param {AsyncIterable<T>} source An async-iterable sequence whose elements to apply the predicate to.
|
9 | * @param {FindOptions<T, S>} options The options which includes a required predicate, an optional
|
10 | * thisArg for binding, and an abort signal for cancellation.
|
11 | * @returns {Promise<boolean>} A promise with a boolean determining whether any elements in the source sequence
|
12 | * pass the test in the specified predicate.
|
13 | */
|
14 | export async function some(source, options) {
|
15 | const { ['signal']: signal, ['thisArg']: thisArg, ['predicate']: predicate } = options;
|
16 | throwIfAborted(signal);
|
17 | let i = 0;
|
18 | for await (const item of wrapWithAbort(source, signal)) {
|
19 | if (await predicate.call(thisArg, item, i++, signal)) {
|
20 | return true;
|
21 | }
|
22 | }
|
23 | return false;
|
24 | }
|
25 |
|
26 | //# sourceMappingURL=some.mjs.map
|