import { cycle } from "https://deno.land/x/aitertools@0.6.0/src/infinite.ts";
Makes an async iterator that yields elements from the source
and saving
a copy of each. When the source
is exhausted, yields saved copies
indefinitely.
Note that it may require significant memory to save the copies
depending on the length of the source
.
import { cycle } from "./infinite.ts";
async function* gen() { yield 3; yield 6; yield 9; }
const iterable = cycle(gen());
for await (const value of iterable) console.log(value);
The above example will print the following and keep going forever:
3
6
9
3
6
9
(...)