# reduce-reducers

> Reduce multiple reducers into a single reducer

Latest version **1.0.4** (published 2019-05-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install reduce-reducers
pnpm add reduce-reducers
yarn add reduce-reducers
bun add reduce-reducers
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2019-05-05 |
| First published | 2015-07-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 783 |
| Author | Andrew Clark |
| Maintainers | acdlite, timche |
| Keywords | reduce, reducers, redux |

## Links

- npm: https://www.npmjs.com/package/reduce-reducers
- Repository: https://github.com/redux-utilities/reduce-reducers
- Homepage: https://github.com/redux-utilities/reduce-reducers#readme
- Issues: https://github.com/redux-utilities/reduce-reducers/issues
- npm.io page: https://npm.io/package/reduce-reducers

## Recent versions

- 1.0.4 (latest) — 2019-05-05
- 1.0.3 — 2019-05-05
- 1.0.2 — 2019-05-02
- 1.0.1 — 2019-03-26
- 1.0.0 — 2019-03-26
- 0.4.3 — 2018-07-20
- 0.4.2 — 2018-07-19
- 0.4.1 — 2018-07-19
- 0.4.0 — 2018-07-19
- 0.3.0 — 2018-05-01
- 0.2.0 — 2018-04-20
- 0.1.5 — 2018-04-16
- 0.1.2 — 2016-02-02
- 0.1.1 — 2015-07-02
- 0.1.0 — 2015-07-02

## README

# reduce-reducers

[![Build Status](https://travis-ci.org/redux-utilities/reduce-reducers.svg?branch=master)](https://travis-ci.org/redux-utilities/reduce-reducers)
[![npm Version](https://img.shields.io/npm/v/reduce-reducers.svg)](https://www.npmjs.com/package/reduce-reducers)
[![npm Downloads Monthly](https://img.shields.io/npm/dm/reduce-reducers.svg)](https://www.npmjs.com/package/reduce-reducers)

> Reduce multiple reducers into a single reducer from left to right

## Install

```
npm install reduce-reducers
```

## Usage

```js
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 }
```

## FAQ

#### Why?

Originally created to combine multiple Redux reducers that correspond to different actions (e.g. [like this](https://github.com/acdlite/redux-fsa/blob/master/src/handleActions.js#L12)). Technically works with any reducer, not just with Redux, though I don't know of any other use cases.

#### What is the difference between `reduceReducers` and `combineReducers`?

This StackOverflow post explains it very well: https://stackoverflow.com/a/44371190/5741172

---
_Source: https://npm.io/package/reduce-reducers · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
