{"_id":"@bitalikrty/redux-create-reducer","_rev":"1-a86f1e5f961d242367a1b5ef7b21593a","name":"@bitalikrty/redux-create-reducer","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@bitalikrty/redux-create-reducer","version":"1.0.0","description":"[![NPM version][npm-image]][npm-url] [![Build status][travis-image]][travis-url] [![Test coverage][coveralls-image]][coveralls-url] [![Downloads][downloads-image]][downloads-url]","main":"./index.js","scripts":{"test-cov":"node ./node_modules/istanbul/lib/cli.js cover -x test.js node_modules/mocha/bin/_mocha 'test.js' -- --reporter dot","test-travis":"node ./node_modules/istanbul/lib/cli.js cover -x test.js ./node_modules/mocha/bin/_mocha 'test.js' -- -R spec && npm run ts-test","ts-test":"tsc --noEmit ts-test","test":"mocha && npm run ts-test"},"author":{"name":"Vitalik Yatsenko"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/bitalikr1999/react-redux-reducer.git"},"keywords":["redux","reducer"],"types":"index.d.ts","devDependencies":{"babel-core":"^6.26.3","coveralls":"^3.0.2","expect":"^1.14.0","istanbul":"^0.4.5","mocha":"^5.2.0","redux":"^4.0.1","typescript":"^3.3.3333"},"peerDependencies":{"redux":"*"},"gitHead":"4f7994298c0d656c9f4a5fc538bf9d650f28876a","bugs":{"url":"https://github.com/bitalikr1999/react-redux-reducer/issues"},"homepage":"https://github.com/bitalikr1999/react-redux-reducer#readme","_id":"@bitalikrty/redux-create-reducer@1.0.0","_nodeVersion":"11.15.0","_npmVersion":"6.14.2","dist":{"integrity":"sha512-9A3Wdnk3n/GFhL/k+qlGCP+FmI5IwKsb/Ir7pNbfx9EWBFLpCufJQL2Jsex1Az7/tjh6pNrudixn4V9QwFg05A==","shasum":"5a31f1eb5ec7463a0b7041157cbc023836b4ded9","tarball":"https://registry.npmjs.org/@bitalikrty/redux-create-reducer/-/redux-create-reducer-1.0.0.tgz","fileCount":7,"unpackedSize":9130,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeco63CRA9TVsSAnZWagAARDEP/21GNynjrasgvLXDmDQc\nh+g6VAidyUZSoDeRgmSqq+Ujg5GGsSroexoWMMAql+Ue7HkTupzr/RXn/VC4\ns64tM534fWBgObe9bkIRTic6uTlzjjcCbQptqs+Oe+K2enJL2X2ZK7d/xx14\nMf3lLU9HwZu4ZlTQu2/h1iGChsXmmzXK9dVA9+HfrqcGEuZsSdkFLmVx2tcK\nKSTNrES7rRT2wc6SAU1wBfy4uQtjVJn3jbRScXq6xEUAKOIxhiliFx7HlDy8\nxfzBBNi+EjpkbrN78Jy47QjP4PXY04jGSGzg4RHW+kArc74LK1ISqOfbL/6B\n3v/pScD72d2gpE15Tdc8zgN0231yi3hpQMxxd6sQQQxekVioKDy+AFJq+jqS\nxYwCtVKyg+ecVZnrYeHqyZ1NNE2Q+5v0IJi8TLUkvS6si8r7caFznHxADsdx\nUNjl01cTGgzGUlXRXb1+uNMOJ1FhrZH8fMhVy5wtCG6NteWvYMWkobIF/upO\nReZiwrj5Z9oLUR0uUJY1Xjj5tptiOwhwbcL3zwHPAH5GZrVIjbu+OqpcjtNa\nvpHMn/z7XsE9lcjwyfAHhi4rf12Bu9wwlO95VPrh3Hs1hMvljcIDCs0AYPL7\nWgbe9X2FjdX5YWm6sGL53lvBjUWTQ3zgQLvYrMUwEqP6cgfKpNORhKRZxRMK\n9hCm\r\n=zVIc\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAC6/oU1wv86ugDAH9VI2q80yQwm1Q8Tyo+KMyYE7PFxAiEA/QxwJvJY/upppYpTljdlEPdtJ9dzHvwIrFR3FnOuWLI="}]},"maintainers":[{"name":"bitalikrty","email":"bitalikrty@gmail.com"}],"_npmUser":{"name":"bitalikrty","email":"bitalikrty@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/redux-create-reducer_1.0.0_1584565942657_0.20206793476955287"},"_hasShrinkwrap":false}},"time":{"created":"2020-03-18T21:12:22.416Z","1.0.0":"2020-03-18T21:12:22.782Z","modified":"2022-04-04T18:57:09.301Z"},"maintainers":[{"name":"bitalikrty","email":"bitalikrty@gmail.com"}],"description":"[![NPM version][npm-image]][npm-url] [![Build status][travis-image]][travis-url] [![Test coverage][coveralls-image]][coveralls-url] [![Downloads][downloads-image]][downloads-url]","homepage":"https://github.com/bitalikr1999/react-redux-reducer#readme","keywords":["redux","reducer"],"repository":{"type":"git","url":"git+https://github.com/bitalikr1999/react-redux-reducer.git"},"author":{"name":"Vitalik Yatsenko"},"bugs":{"url":"https://github.com/bitalikr1999/react-redux-reducer/issues"},"license":"MIT","readme":"# redux-create-reducer\n\n[![NPM version][npm-image]][npm-url]\n[![Build status][travis-image]][travis-url]\n[![Test coverage][coveralls-image]][coveralls-url]\n[![Downloads][downloads-image]][downloads-url]\n\n[This code packaged as a node module](http://redux.js.org/docs/recipes/ReducingBoilerplate.html#generating-reducers)\n\nUsage:\n\n```js\nimport { createReducer } from 'redux-create-reducer';\nimport * as ActionTypes from '../constants/ActionTypes';\n\nconst initialState = [];\n\nexport const todos = createReducer(initialState, {\n  [ActionTypes.ADD_TODO](state, action) {\n    const text = action.text.trim();\n    return [...state, text];\n  },\n\n  [ActionTypes.REMOVE_TODO](state, action) {\n    return state.filter((_, i) => i !== action.index);\n  }\n\n  // All other action types result in state being returned\n})\n```\n\n## Typescript typings\n\nThis library also provides powerful typescript typings when using Action classes:\n\n```ts\ninterface Action {\n  type: string;\n}\n\ninterface State {\n  value: number;\n}\n\nclass Reset implements Action {\n  readonly type = 'Reset Action';\n}\nclass AddOne implements Action {\n  readonly type = 'AddOne Action';\n}\nclass AddCustom implements Action {\n  readonly type = 'AddCustom Action';\n  constructor(public readonly value: number) { }\n}\n\ntype Actions = Reset | AddOne | AddCustom;\n\nconst reducer = createReducer<State, Actions>({ value: 0 }, {\n  'Reset Action': (state, action) => ({ value: 0 }),\n  'AddOne Action': (state, action) => ({ value: state.value + 1 }),\n  'AddCustom Action': (state, action) => ({ value: state.value + action.value }),\n});\n\n// If you wanted to exclude some actions you can use the `Exclude` type.\ntype ActionsWithoutAddOne = Exclude<Actions, AddOne>\nconst reducerThatDoesNotHandleAddOne = createReducer<State, ActionsWithoutAddOne>({ value: 0 }, {\n  'Reset Action': (state, action) => ({ value: 0 }),\n  'AddCustom Action': (state, action) => ({ value: state.value + action.value }),\n});\n```\n[Stackblitz](https://stackblitz.com/edit/typescript-b5ekwc?file=index.ts)\n\nRemoving `'Reset Action': (state, action) => ({ value: 0 }),` in the reducer causes the error: `Property '\"Reset Action\"' is missing in type ...`. Similarly, adding `'Nonexisting Action': (state, action) => ({ value: 0 }),` causes the type error: `Object literal may only specify known properties, and ''Nonexisting Action'' does not exist in type 'Handlers<State, Actions>'.ts(2345)`\n\n[npm-image]: https://img.shields.io/npm/v/redux-create-reducer.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/redux-create-reducer\n[travis-image]: https://img.shields.io/travis/kolodny/redux-create-reducer.svg?style=flat-square\n[travis-url]: https://travis-ci.org/kolodny/redux-create-reducer\n[coveralls-image]: https://img.shields.io/coveralls/kolodny/redux-create-reducer.svg?style=flat-square\n[coveralls-url]: https://coveralls.io/r/kolodny/redux-create-reducer\n[downloads-image]: http://img.shields.io/npm/dm/redux-create-reducer.svg?style=flat-square\n[downloads-url]: https://npmjs.org/package/redux-create-reducer\n","readmeFilename":"README.md"}