Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

scan

import { scan } from "https://github.gh-proxy.cn/raw.githubusercontent.com/baetheus/fun/main/async_iterable.ts";

Scan over an AsyncIterable, yielding intermediate results.

@example
import { scan } 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 = pipe(
  numbers,
  scan((acc, value) => acc + value, 0)
);

for await (const value of runningSum) {
  console.log(value); // 0, 1, 3, 6, 10, 15
}
function scan<A, O>(scanner: (accumulator: O, value: A) => O, seed: O): (ta: AsyncIterable<A>) => AsyncIterable<O>;
§
scan<A, O>(scanner: (accumulator: O, value: A) => O, seed: O): (ta: AsyncIterable<A>) => AsyncIterable<O>
[src]

§Type Parameters

§Parameters

§
scanner: (accumulator: O, value: A) => O
[src]
§
seed: O
[src]

§Return Type

§
(ta: AsyncIterable<A>) => AsyncIterable<O>
[src]