This project has been succeeded by GraphReFly. New development happens at graphrefly-ts. npm install @graphrefly/graphrefly
Skip to content

reduce() ​

Folds a finite stream into one value, emitting once on upstream completion (Tier 2).

Signature ​

ts
function reduce<A, B>(reducer: (acc: B, value: A) => B, seed: B): StoreOperator<A, B>

Parameters ​

ParameterTypeDescription
reducer(acc: B, value: A) =&gt; BPure fold; must not mutate acc if seed is mutable (use immutable updates).
seedBInitial accumulator; also emitted if upstream completes without DATA.

Returns ​

StoreOperator&lt;A, B&gt; — errors propagate without emission.

Options / Behavior Details ​

  • Immutability: Mutating seed breaks resubscribe semantics; prefer [...acc, v] or toArray().

See Also ​

Released under the MIT License.