0.2.3 • Published 7 years ago

reduce-merge-reducers v0.2.3

Weekly downloads
111
License
MIT
Repository
github
Last release
7 years ago

reduce-merge-reducers

build status npm version

Reduce multiple reducers into a single reducer from left to right and merge their initial states.

:warning: in order to avoid unexpected results one should use plain objects as initial states

npm install --save reduce-merge-reducers

Example

const reducer = reduceMergeReducers(
  (state = { C: 3 }) => state,
  (state = { D: 5 }) => state,
);

expect(reducer(undefined)).to.deep.equal({ C: 3, D: 5 });

Why?

This package is a variant of reduce-reducers supporting initial state. The implementation is based on naorye suggestion regarding the following issue https://github.com/acdlite/reduce-reducers/issues/9