repeat<T>(value: T,times?,): AsyncIterableIterator<T>
Makes an async iterator that yields the same value over and over again.
It will repeat indefinitely unless times is specified.
import { repeat } from "./infinite.ts"; const iterable = repeat("v"); for await (const value of iterable) console.log(value);
The above example will print the following and keep going forever:
v v v (...)
However, if you specify the second parameter times it will repeat that many
times:
import { repeat } from "./infinite.ts"; const iterable = repeat("V", 3); for await (const value of iterable) console.log(value);
The above example will print the following 3 lines:
V V V
value: T
The value to repeat.
AsyncIterableIterator<T>
An async iterable that repeats the value indefinitely or
times times.