Skip to content

Commit

Permalink
add createReducer
Browse files Browse the repository at this point in the history
  • Loading branch information
chee committed Feb 2, 2017
1 parent fcaa958 commit c41672f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions index.js
@@ -0,0 +1,8 @@
const objectDefault = require('object-with-default-value')

module.exports = function createReducer({reducers = {}, defaultState = {}} = {}) {
reducers = objectDefault(reducers, state => state)
return (state = defaultState, action = {}) => (
reducers[action.type](state, action)
)
}
4 changes: 2 additions & 2 deletions package.json
@@ -1,7 +1,7 @@
{
"name": "create-reducers",
"name": "create-reducer",
"version": "1.0.0",
"description": "create reducers to use with data-based control flow",
"description": "create reducer that uses data-based control flow",
"main": "index.js",
"author": "chee <chee@snake.dog>",
"license": "MIT",
Expand Down

0 comments on commit c41672f

Please sign in to comment.