fold
import { fold } from "https://github.gh-proxy.cn/raw.githubusercontent.com/baetheus/fun/main/async_iterable.ts";Fold over an AsyncIterable to produce a single value.
@example
import { fold } from "./async_iterable.ts";
import { fromIterable } from "./async_iterable.ts";
import { pipe } from "./fn.ts";
const numbers = fromIterable([1, 2, 3, 4, 5]);
const sum = await pipe(
numbers,
fold((acc, value) => acc + value, 0)
);
console.log(sum); // 15
function fold<A, O>(foldr: (
value: O,
accumulator: A,
index: number,
) => O, initial: O): (ta: AsyncIterable<A>) => Promise<O>;