Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/stream_observables/sinks/mod.ts>reduce

A collection of observables built with ReadableStreams & friends.
Latest
function reduce
import { reduce } from "https://deno.land/x/stream_observables@v1.3/sinks/mod.ts";

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

Parameters

Observable to reduce.

f: ScanFunc<U, T>

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

v0: U

Initial accumulator value.

Returns

Promise<U>

Promise that resolves with the accumulated value.