summaryrefslogtreecommitdiffstats
path: root/packages/gitbook-core/src/composeReducer.js
blob: fa2a5899d52fe6bd9e07b979897c6cc9c7750fb2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

/**
 * Compose multiple reducers into one
 * @param  {Function} reducers
 * @return {Function}
 */
function composeReducer(...reducers) {
    return (state, action) => {
        return reducers.reduce(
            (newState, reducer) => reducer(newState, action),
            state
        );
    };
}

module.exports = composeReducer;