Function every

  • Standard Array.every logic for the iterable, extended with iteration state + async.

    It emits a boolean, indicating whether all elements pass the predicate test.

    import {pipe, every} from 'iter-ops';

    const i = pipe(
    [1, 2, 3],
    every(a => a % 2 === 0) // checks if every number is even
    );

    console.log(...i); //=> false

    console.log(i.first); //=> false

    Note that the predicate can only return a Promise inside an asynchronous pipeline, or else the Promise will be treated as a truthy value.

    Type Parameters

    • T

    Parameters

    • cb: ((value: T, index: number, state: IterationState) => boolean | Promise<boolean>)
        • (value, index, state): boolean | Promise<boolean>
        • Parameters

          Returns boolean | Promise<boolean>

    Returns Operation<T, boolean>