Function some

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

    It emits a boolean, indicating whether at least one element passes the predicate test.

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

    const i = pipe(
    [1, 2, 3],
    some(a => a % 2 === 0) // checks if even numbers are present
    );

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

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

    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>