| 1 2 3 4 5 6 7 8 9 10 11 12 13 | 4x 1x 3x 4x | export default function createObjectMapReducer(initialState, handlers, ...initialArgs) {
if (typeof handlers !== 'object') {
throw new TypeError(
`[reducer-generator-object-map]: received an invalid "handlers" argument. Expected object but got ${typeof handlers}`,
);
}
return (state = initialState, action, ...reducerArgs) =>
!action || !action.type || typeof handlers[action.type] !== 'function'
? state
: handlers[action.type](state, action, ...initialArgs, ...reducerArgs);
}
|