UNPKG

879 BJavaScriptView Raw
1/**
2 * Determines whether any element of an iterable sequence satisfies a condition.
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 {FindSubclassedOptions<T, S>} options The options which includes a required predicate, an optional
8 * thisArg for binding, and an abort signal for cancellation.
9 * @returns {boolean} Returns a boolean determining whether any elements in the source sequence
10 * pass the test in the specified predicate.
11 */
12export function some(source, options) {
13 const { ['thisArg']: thisArg, ['predicate']: predicate } = options;
14 let i = 0;
15 for (const item of source) {
16 if (predicate.call(thisArg, item, i++)) {
17 return true;
18 }
19 }
20 return false;
21}
22
23//# sourceMappingURL=some.mjs.map