From 7f7e523d384611e5fd681035f4ef9b0b3983f92f Mon Sep 17 00:00:00 2001 From: Louis Capitanchik <contact@louiscap.co> Date: Sun, 29 Jan 2017 15:29:09 +0000 Subject: [PATCH] redux-reducer --- index.js | 8 ++++++++ package.json | 9 +++++++++ 2 files changed, 17 insertions(+) create mode 100644 index.js create mode 100644 package.json diff --git a/index.js b/index.js new file mode 100644 index 0000000..ee08eab --- /dev/null +++ b/index.js @@ -0,0 +1,8 @@ +module.exports = function(initial, handlers) { + return function(state = initial, {type, ...action}) { + if (handlers.hasOwnProperty(type)) { + return handlers[type](state, action) + } + return state + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..9f4ae2d --- /dev/null +++ b/package.json @@ -0,0 +1,9 @@ +{ + "name": "@commander-lol/redux-reducer", + "version": "1.0.0", + "description": "Remove the boilerplate for creating redux reducers", + "main": "index.js", + "repository": {}, + "author": "Louis Capitanchik <contact@louiscap.co>", + "license": "BSD-2-Clause" +} -- GitLab