Skip to main content

cycle

Callable


  • Creates a generator cycles through the given Mappable.

    The generator makes the given Mappable applicative before cycling through it. This ensures the cycle is reentrant.

    Example

    collect(take(cycle([1, 2]), 4))
    // => [1, 2, 1, 2]

    function* foobar() {
    yield 'foo'
    yield 'bar'
    }
    collect(take(counter(foobar), 4))
    // => ["foo", "bar", "foo", "bar"]

    Type parameters

    • T

      The item type.

    Parameters

    Returns InfiniteGenerator<T>

    The cycle generator.