Create an iterator of iterators that repeats n times (defaults to indefinetly).
import { pipe } from "yta";import { of, repeat, take, toArray } from "yta/async";import { asAsync, range } from "yta/sync";await pipe( repeat(() => pipe(range(), asAsync(), take(3))), take(4), map(toArray()), toArray(),);// => [[0, 1, 2], [0, 1, 2], [0, 1, 2], [0, 1, 2]] Copy
import { pipe } from "yta";import { of, repeat, take, toArray } from "yta/async";import { asAsync, range } from "yta/sync";await pipe( repeat(() => pipe(range(), asAsync(), 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.
n
import { pipe } from "yta";import { of, repeat, toArray } from "yta/async";await pipe( repeat(() => of(1, -1), 3), map(toArray()), toArray(),);// => [[1, -1], [1, -1], [1, -1]] Copy
import { pipe } from "yta";import { of, repeat, toArray } from "yta/async";await pipe( repeat(() => of(1, -1), 3), map(toArray()), toArray(),);// => [[1, -1], [1, -1], [1, -1]]
See also:
Optional
Create an iterator of iterators that repeats n times (defaults to indefinetly).
If you provide
nas a second argument, repeat the sequencenmany times.See also: