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

reduce

import { reduce } from "https://raw.githubusercontent.com/surma/observables-with-streams/28c55be6d855780c677fd1f4ba975f4d3144891d/src/index.ts";

Accumulates value, starting with v0 and applying f to each emitted item. If no items are emitted the promise is rejected.

async function reduce<U, T>(
o: Observable<T>,
f: ScanFunc<U, T>,
v0: U,
): Promise<U>;
§
reduce<U, T>(o: Observable<T>, f: ScanFunc<U, T>, v0: U): Promise<U>
[src]

§Type Parameters

§Parameters

§

Observable to reduce.

§
f: ScanFunc<U, T>
[src]

Reduce function called with the accumulated value so far and the current item. Should return a new accumulated value.

§
v0: U
[src]

Initial accumulator value.

§Return Type

§
Promise<U>
[src]

Promise that resolves with the accumulated value.