@lou.codes/iterables
Version:
🔁 Iterable and AsyncIterable utils
25 lines (24 loc) • 811 B
TypeScript
import type {
IsomorphicIterable,
Predicate,
Single,
Unary,
} from "@lou.codes/types";
/**
* Evaluates items in an iterable or asynchronous iterable against a predicate
* and returns `true` if all items evaluates to `true`.
*
* @category Asynchronous Reducers
* @example
* ```typescript
* const everyEven = every((number: number) => number % 2 === 0);
* everyEven([2, 4, 6, 8]); // true
* everyEven([1, 2, 3, 4]); // false
* ```
* @param predicate Predicate function to evaluate each item.
* @returns Curried function with `predicate` set in context.
*/
export declare const every: <Item, Predicated extends Item = never>(
predicate: Single<Predicated> extends Single<never> ? Unary<Item, boolean>
: Predicate<Item, Predicated>,
) => (iterable: IsomorphicIterable<Item>) => Promise<boolean>;