{"_id":"@beardedtim/common-reducers","_rev":"2-7dfdceecd9273205420a34c40b87984d","name":"@beardedtim/common-reducers","description":"> Because I got tired of re-writing these every reducer","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"devDependencies":{"chai":"^3.5.0","mocha":"^3.2.0"},"name":"@beardedtim/common-reducers","version":"0.1.0","main":"index.js","repository":{"type":"git","url":"git+https://github.com/beardedtim/common-reducers.git"},"author":{"name":"Timi","email":"timiroberts@gmail.com","url":"https://github.com/beardedtim"},"license":"MIT","scripts":{"test":"mocha *.spec.js","test:w":"mocha *.spec.js --watch"},"gitHead":"2bd961d2ddd3a284d270a4b48ddf3cc76e9bd3f9","description":"> Because I got tired of re-writing these every reducer","bugs":{"url":"https://github.com/beardedtim/common-reducers/issues"},"homepage":"https://github.com/beardedtim/common-reducers#readme","_id":"@beardedtim/common-reducers@0.1.0","_shasum":"219afaceee1df1ff33e1781d34e669dbd94a1d4b","_from":".","_npmVersion":"4.1.2","_nodeVersion":"7.5.0","_npmUser":{"name":"beardedtim","email":"timiroberts@gmail.com"},"dist":{"shasum":"219afaceee1df1ff33e1781d34e669dbd94a1d4b","tarball":"https://registry.npmjs.org/@beardedtim/common-reducers/-/common-reducers-0.1.0.tgz","integrity":"sha512-MYy3FQ/HQc3TWjK1PcabUavbsmGjx1vUU3Rc3JwjInjn7nDQ2+AHKU2PDmrTUlTW+o9ieycPxGlTHAzLddLtFQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIA16lW290ziby2QNHd0Trfn34IHdUGIo/QycWL1ecDu2AiBadWJXuTD+JpYUc+no0hzup9NVRy8tnMl56CdHPXMIBg=="}]},"maintainers":[{"name":"beardedtim","email":"timiroberts@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/common-reducers-0.1.0.tgz_1486419451468_0.021925697568804026"}}},"readme":"# Common Reducers\n\n> Because I got tired of re-writing these every reducer\n\n## Array Methods\n\n### Usage\n\n```\nimport {add, updateByKey, removeByKey} from '@beardedtim/common-reducers'\nconst reducer = {\n  [ADD_USER]: add,\n  [UPDATE_USER]: updateByKey('_id'),\n  [REMOVE_USER]: removeByKey('_id')\n}\n```\n\nwhich is dependent on the action looking like this:\n\n```\naddUser(user) // {type: ADD_USER, payload: user}\nupdateUser({_id: _id, update}) // {type: UPDATE_USER, payload: {_id,update}}\nremoveUser(_id) // {type: REMOVE_USER, payload: _id}\n```\n\nIf you want to remove more than one item at a time, you can use `unique=false` when creating `removeByKey`:\n\n```\n[REMOVE_MATCHING_NAME]: removeByKey('name',false)\n```\n\nthis will now filter out all objects inside of `state` who have a property called `name` that is set to whatever is passed in by `removeUser`","maintainers":[{"name":"beardedtim","email":"timiroberts@gmail.com"}],"time":{"modified":"2022-06-12T15:05:50.584Z","created":"2017-02-06T22:17:33.233Z","0.1.0":"2017-02-06T22:17:33.233Z"},"homepage":"https://github.com/beardedtim/common-reducers#readme","repository":{"type":"git","url":"git+https://github.com/beardedtim/common-reducers.git"},"author":{"name":"Timi","email":"timiroberts@gmail.com","url":"https://github.com/beardedtim"},"bugs":{"url":"https://github.com/beardedtim/common-reducers/issues"},"license":"MIT","readmeFilename":"README.md"}