
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
reduce-reducers
Advanced tools
Reduce multiple reducers into a single reducer from left to right
npm install reduce-reducers
import reduceReducers from 'reduce-reducers';
const initialState = { A: 0, B: 0 };
const addReducer = (state, payload) => ({ ...state, A: state.A + payload });
const multReducer = (state, payload) => ({ ...state, B: state.B * payload });
const reducer = reduceReducers(initialState, addReducer, multReducer);
const state = { A: 1, B: 2 };
const payload = 3;
reducer(state, payload); // { A: 4, B: 6 }
Originally created to combine multiple Redux reducers that correspond to different actions (e.g. like this). Technically works with any reducer, not just with Redux, though I don't know of any other use cases.
reduceReducers and combineReducers?This StackOverflow post explains it very well: https://stackoverflow.com/a/44371190/5741172
Redux is a popular state management library for JavaScript applications. It provides a combineReducers function that allows you to combine multiple reducers into a single reducer. While reduce-reducers focuses on combining reducers in a more flexible way, Redux's combineReducers is more straightforward and is a core part of the Redux library.
Redux Loop is an alternative to redux-thunk and redux-saga. It allows you to handle side effects in your reducers. While it doesn't directly compete with reduce-reducers, it offers a different approach to managing complex state logic and side effects in Redux applications.
Reducer Composer is another library that allows you to combine multiple reducers into one. It provides a similar functionality to reduce-reducers but with a different API. It focuses on composing reducers in a more functional programming style.
FAQs
Reduce multiple reducers into a single reducer
We found that reduce-reducers demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.