• Creates an Iterable that emits a sequence of values computed by a Mapper function, starting with a seed value. The sequence ends when the hasNext Predicate returns false.

    Example

    Iterate from 1 to 3

    const iterable = iterate(
    1,
    x => x + 1,
    x => x < 3
    );

    console.log(iterable); // [1, 2, 3]

    See

    generate for similar operations.

    Type Parameters

    • T

      the Iterable value type

    Parameters

    • seed: T

      the first value of the sequence

    • next: Mapper<T, T>

      the Mapper function to compute the next value

    • hasNext: Predicate<[T]> = alwaysTrue

      the Predicate to check if there's a next value

    Returns IterableIterator<T>

Generated using TypeDoc