Referencereduce
Reference · 91
reduce
reduce
Accumulates like Array.reduce, but emits only the final result on complete.
Signature
reduce(accumulator: (acc: R, value: T, index: number) => R, seed: R): OperatorFunction
What it does
Holds an accumulator and updates it on each next. Unlike scan, it emits only the final value after the source completes.
When to use
Sums, dictionaries, summary reports, reducing a finite stream to a single result.
Gotcha
On an infinite stream, reduce never emits.
See also
scan, toArray, count
script.ts
CONSOLE · Console output
Hit Run to see the result...