yta
    Preparing search index...

    Function repeat

    • Create an iterator of iterators that repeats n times (defaults to indefinetly).

      import { pipe } from "yta";
      import { range, repeat, take, toArray } from "yta/sync";

      pipe(
      repeat(() => pipe(range(), take(3))),
      take(4),
      map(toArray()),
      toArray(),
      );
      // => [[0, 1, 2], [0, 1, 2], [0, 1, 2], [0, 1, 2]]

      If you provide n as a second argument, repeat the sequence n many times.

      import { pipe } from "yta";
      import { of, repeat, toArray } from "yta/sync";

      pipe(
      repeat(() => of(1, -1), 3),
      map(toArray()),
      toArray(),
      );
      // => [[1, -1], [1, -1], [1, -1]]

      See also:

      Type Parameters

      • A
      • I extends Iterable<A, any, any>

      Parameters

      • generator: () => I
      • Optionaltimes: number = Number.POSITIVE_INFINITY

      Returns Generator<I, void, any>