yta
    Preparing search index...

    Function cycle

    • Create a cycle of an iterator such that when finished with one run, start the same sequence over.

      Note that the items are internally buffered, which might be problematic for long iterators (especially infinite ones). Consider using repeat or flatRepeat if you can.

      import { pipe } from "yta";
      import { cycle, of, take } from "yta/sync";

      pipe(of(1, -1), cycle(), take(5), toArray());
      // => [1, -1, 1, -1, 1]

      See also:

      Type Parameters

      • A

        The item type

      Returns (items: Iterable<A>) => Generator<A, void>