loop
import { loop } from "https://github.gh-proxy.cn/raw.githubusercontent.com/baetheus/fun/main/async_iterable.ts";Transform an AsyncIterable using a stateful stepper function.
@example
import { loop, collect } from "./async_iterable.ts";
import { fromIterable } from "./async_iterable.ts";
import { pipe } from "./fn.ts";
const numbers = fromIterable([1, 2, 3, 4, 5]);
const runningSum = loop(
(sum: number, value: number) => [sum + value, sum + value],
0
);
const result = await pipe(
numbers,
runningSum,
collect
);
console.log(result); // [1, 3, 6, 10, 15]
function loop<A, B, S>(stepper: (state: S, value: A) => [S, B], seed: S): (ua: AsyncIterable<A>) => AsyncIterable<B>;