The type of values in the async iterable
Function to test each value with its index
A consumer function that returns a promise resolving to a boolean
This function tests whether all values in an async iterable pass the given predicate function.
It returns true if every value passes the test, and false as soon as it encounters any
value that fails. Similar to Array.prototype.every(), but works with async iterables and
supports both synchronous and asynchronous predicates.
The function short-circuits and returns false as soon as it finds a value that doesn't
pass the predicate, without processing the remaining values.
// Check if all numbers are positive
const allPositive = await G.pipe(
G.ofIterable([1, 2, 3, 4, 5]),
G.every(x => x > 0)
); // true
const hasNegative = await G.pipe(
G.ofIterable([1, 2, -3, 4, 5]),
G.every(x => x > 0)
); // false
// With async predicate
const allValid = await G.pipe(
G.ofIterable(users),
G.every(async user => {
const isValid = await validateUser(user);
return isValid;
})
);
Creates a consumer that checks if all values in an async iterable satisfy a predicate.