{"_id":"@commander-lol/redux-reducer","_rev":"3-0e765f4adc5b52b12fe8c0c2e53aa497","name":"@commander-lol/redux-reducer","description":"Remove the boilerplate for creating redux reducers","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@commander-lol/redux-reducer","version":"1.0.0","description":"Remove the boilerplate for creating redux reducers","main":"index.js","author":{"name":"Louis Capitanchik","email":"contact@louiscap.co"},"license":"BSD-2-Clause","keywords":["redux","reducer","utils","utility"],"repository":{"type":"git","url":"git+ssh://git@github.com/Commander-lol/redux-reducer.git"},"gitHead":"00475863a7d206e16eed63ed7d2d075851d68ebc","bugs":{"url":"https://github.com/Commander-lol/redux-reducer/issues"},"homepage":"https://github.com/Commander-lol/redux-reducer#readme","_id":"@commander-lol/redux-reducer@1.0.0","scripts":{},"_shasum":"7f822994f715427c3cdf1bd47fcec148a0d201a7","_from":".","_npmVersion":"3.10.8","_nodeVersion":"7.0.0","_npmUser":{"name":"commander-lol","email":"contact@louiscap.co"},"dist":{"shasum":"7f822994f715427c3cdf1bd47fcec148a0d201a7","tarball":"https://registry.npmjs.org/@commander-lol/redux-reducer/-/redux-reducer-1.0.0.tgz","integrity":"sha512-k3kC6PncR94akfY5CVqriPST3ansaOQ7Oi0pfnTXziYLGxoN12KGLofRLquJIKXy91eXM3zE/fhs1zCm7/qohA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCNsAFrRtVJgYOS/MMUN4j3tscLEZX0vQSrvGvk4zIccgIhAP0toroarro6+WxmGYBQ/SU1lqRt9fS36azQiAGI6sds"}]},"maintainers":[{"name":"commander-lol","email":"contact@louiscap.co"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/redux-reducer-1.0.0.tgz_1485703912567_0.8726679128594697"}},"1.0.1":{"name":"@commander-lol/redux-reducer","version":"1.0.1","description":"Remove the boilerplate for creating redux reducers","main":"index.js","author":{"name":"Louis Capitanchik","email":"contact@louiscap.co"},"license":"BSD-2-Clause","keywords":["redux","reducer","utils","utility"],"repository":{"type":"git","url":"git+ssh://git@github.com/Commander-lol/redux-reducer.git"},"gitHead":"0800bbd8959b76162b1c17d5b63bb5f092c1cffa","bugs":{"url":"https://github.com/Commander-lol/redux-reducer/issues"},"homepage":"https://github.com/Commander-lol/redux-reducer#readme","_id":"@commander-lol/redux-reducer@1.0.1","scripts":{},"_shasum":"bb656f975dccf3fdea77f681f7bebcba5e8f886f","_from":".","_npmVersion":"3.10.8","_nodeVersion":"7.0.0","_npmUser":{"name":"commander-lol","email":"contact@louiscap.co"},"dist":{"shasum":"bb656f975dccf3fdea77f681f7bebcba5e8f886f","tarball":"https://registry.npmjs.org/@commander-lol/redux-reducer/-/redux-reducer-1.0.1.tgz","integrity":"sha512-KFijSnVi7Rxz/ear8ZzbxOw90iViKoBmM/k1rzB0EfdQNcb8WqfUgTVDTdVF/6sx+NtfcJhSJEVsaHiCk6o1pA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIG3wbL2K9C/WMWPv4A24LkD45hYsPfyHTyKwot8A8AN/AiAf2h4b8dw01Q+E9rKA6sgRWhr58bBDZN9xmOu4xZfhYw=="}]},"maintainers":[{"name":"commander-lol","email":"contact@louiscap.co"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/redux-reducer-1.0.1.tgz_1485708735192_0.03152211499400437"}}},"readme":"# redux-reducer\nEven simpler reducers with 0 boilerplate\n\n## Installation\n\nOne of the following:\n- `npm i -S @commander-lol/redux-reducer`\n- `yarn add @commander-lol/redux-reducer`\n- `ied i -S @commander-lol/redux-reducer`\n\n## Why?\n\nredux-reducer strips out the common boilerplate used to determine what actions to take when a reducer is run, as well as allowing\nyou to programmatically compose a reducer at runtime. It also handles the default case for you, saving potentially hours\nof bug hunting when you overlook it.\n\n## Usage\n\nWhen you're writing reducers for Redux, you probably have something similar to the following:\n\n```js\nconst initialState = {\n  dongles: {},\n}\n\nexport default function myReducer(state = initialState, {type, ...action}) {\n  switch(type) {\n    case \"ADD_DONGLE\": {\n      let { dongles } = state\n      let { dongle } = action\n      dongles = {\n        ...dongles,\n        [dongle.id]: dongle,\n      }\n      \n      return {\n        ...state,\n        dongles,\n      }\n    }\n    default: \n      return state\n  }\n}\n```\n\nAnd that's a pattern that will appear in pretty much every one of your reducers. Instead, using the `redux-reducer` library\nturns that into the following: \n\n```js\nconst reducer = require('@commander-lol/redux-reducer')\n\nconst initialState = {\n  dongles: {},\n}\n\nexport default reducer(initialState, {\n  ADD_DONGLE: ({ dongles, ...state }, { dongle }) => {\n    return {\n      ...state,\n      dongles: {\n        ...dongles,\n        [dongle.id] = dongle,\n      },\n    }\n  }\n})\n```\n\n## API\n\nThe library exports a single function that returns a redux-compatible reducer function;\n\n``` reducer(initial: Object, handlers: Map<string, Handler>) ```\n\nWhere initial is the `initial` router state and `handlers` is a string -> function map of action types to action reducers. Each handler is passed `state` and `action` as parameters, which correspond to the assigned reducer state and the current action and should return the new version of state after resolving the action. Simple as that.\n","maintainers":[{"name":"commander-lol","email":"contact@louiscap.co"}],"time":{"modified":"2022-06-12T16:23:12.152Z","created":"2017-01-29T15:31:54.497Z","1.0.0":"2017-01-29T15:31:54.497Z","1.0.1":"2017-01-29T16:52:15.758Z"},"homepage":"https://github.com/Commander-lol/redux-reducer#readme","keywords":["redux","reducer","utils","utility"],"repository":{"type":"git","url":"git+ssh://git@github.com/Commander-lol/redux-reducer.git"},"author":{"name":"Louis Capitanchik","email":"contact@louiscap.co"},"bugs":{"url":"https://github.com/Commander-lol/redux-reducer/issues"},"license":"BSD-2-Clause","readmeFilename":"README.md"}