Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "iter/cycle"

Index

Functions

Functions

cycle

  • cycle<T>(input: Iterable<T>, num?: number): Generator<T, void, undefined>
  • Iterator which yields an infinite repetition of given input iterable's values. Produces no values if input is empty. If num is given, only that many cycles will be emitted.

    remarks

    Also see repeat, repeatedly for related functions.

    example
    // take 5 from infinite sequence
    [...take(5, cycle([1, 2, 3]))]
    // [1, 2, 3, 1, 2]
    
    // only produce 2 cycles
    [...cycle(range(3), 2)]
    // [ 0, 1, 2, 0, 1, 2 ]

    Type parameters

    • T

    Parameters

    • input: Iterable<T>

      -

    • Default value num: number = Infinity

      -

    Returns Generator<T, void, undefined>

Generated using TypeDoc