UNPKG

831 BJavaScriptView Raw
1/**
2 * Determines whether all elements of an iterable sequence satisfy 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 {FindOptions<T>} options The options for a predicate for filtering, thisArg for binding and AbortSignal for cancellation.
8 * @returns {boolean} A boolean determining whether all elements in the source sequence pass the test in the specified predicate.
9 */
10export function every(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 false;
16 }
17 }
18 return true;
19}
20
21//# sourceMappingURL=every.mjs.map