Function takeUntil

  • Takes values until the predicate test succeeds. The value for which predicate succeeds is excluded.

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

    const i = pipe(
    [1, 2, 3, 4, 5],
    takeUntil(a => a > 2) // take until value > 2
    );

    console.log(...i); //=> 1, 2

    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, T>