{"id":31691241,"url":"https://github.com/cpnota/redux-collect","last_synced_at":"2025-10-08T13:20:48.826Z","repository":{"id":57149575,"uuid":"83252361","full_name":"cpnota/redux-collect","owner":"cpnota","description":"A utility for converting redux reducers into a collections","archived":false,"fork":false,"pushed_at":"2017-03-02T03:45:59.000Z","size":21,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-22T05:33:47.710Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cpnota.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-27T00:34:58.000Z","updated_at":"2019-02-23T22:56:31.000Z","dependencies_parsed_at":"2022-08-24T10:00:52.184Z","dependency_job_id":null,"html_url":"https://github.com/cpnota/redux-collect","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/cpnota/redux-collect","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cpnota%2Fredux-collect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cpnota%2Fredux-collect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cpnota%2Fredux-collect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cpnota%2Fredux-collect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cpnota","download_url":"https://codeload.github.com/cpnota/redux-collect/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cpnota%2Fredux-collect/sbom","scorecard":{"id":306684,"data":{"date":"2025-08-11","repo":{"name":"github.com/cpnota/redux-collect","commit":"0b128f5229cdb2ea07feebe79f11425ea749d02d"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/17 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-17T22:13:45.255Z","repository_id":57149575,"created_at":"2025-08-17T22:13:45.255Z","updated_at":"2025-08-17T22:13:45.255Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278949791,"owners_count":26074099,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-10-08T13:20:46.766Z","updated_at":"2025-10-08T13:20:48.821Z","avatar_url":"https://github.com/cpnota.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# redux-collect\n\nA utility for converting a [redux](http://redux.js.org) reducer into a collection.\n\n`npm install --save redux-collect`\n\n## Usage\n\n```javascript\n// es6 modules\nimport { collectReducer, collectSelectors, collectActions } from 'redux-collect'\n```\n\n```javascript\n// require syntax\nconst { collectReducer, collectSelectors, collectActions } = require('redux-collect')\n```\n\n## Example\n\nSee the `examples` folder for a full, runnable example.\n\nSay you have a\n[reducer](http://redux.js.org/docs/basics/Reducers.html),\n[selectors](http://redux.js.org/docs/recipes/ComputingDerivedData.html),\nand [actions](http://redux.js.org/docs/basics/Actions.html),\nrepresenting a single entity, such as:\n\n```javascript\nconst carReducer = (state, action) =\u003e {\n  switch (action.type) {\n    case types.ADD:\n      return action.car\n    case types.SET_PRICE:\n      return Object.assign({}, state, { price: action.price })\n    default:\n      return state\n  }\n}\n\nconst carSelectors = {\n  getPrice: state =\u003e state.price,\n  isModel: (state, model) =\u003e state.model === model\n}\n\nconst carActions = {\n  add: car =\u003e ({\n    car,\n    type: types.ADD\n  }),\n  setPrice: price =\u003e ({\n    price,\n    type: types.SET_PRICE\n  }),\n  fetch: url =\u003e dispatch =\u003e get(url).then(car =\u003e dispatch(add(car)))\n}\n```\n\nAs your application grows, you may want to be able to represent multiple cars, stored based on VIN (Vehicle Identification Numbers).\n`redux-collect` makes it easy to reuse your existing functions:\n\n```javascript\nconst reducer = collectReducer(carReducer, 'vin')\nconst selectors = collectSelectors(carSelectors)\nconst actions = collectActions(carActions, 'vin')\n```\n\nThe resulting reducer, selectors, and actions now behave as a collection:\n\n```javascript\n// state is now a collection\nconst store = createStore(reducer, {\n  \"1G6KD54Y73U255447\": {\n    \"make\": \"Jeep\",\n    \"model\": \"Renegade\",\n    \"price\": 25000\n  },\n  \"1FDSF34F13EB85525\": {\n    \"make\": \"Chevrolet\",\n    \"model\": \"Corvette\",\n    \"price\": 45000\n  }\n})\n\n// selectors and actions now take an additional VIN parameter\nselectors.getPrice(store.getState(), \"1G6KD54Y73U255447\") // 25000\n\n// the reducer handles the new action\nstore.dispatch(updatePrice('1G6KD54Y73U255447', 30000))\n\n// the state is updated properly\nselectors.getPrice(store.getState(), \"1G6KD54Y73U255447\") // 30000\n\n// store remains transparent and serializable\nconsole.log(store.getState())\n// \"1G6KD54Y73U255447\": {\n//   \"make\": \"Jeep\",\n//   \"model\": \"Renegade\",\n//   \"price\": 30000\n// },\n// \"1FDSF34F13EB85525\": {\n//   \"make\": \"Chevrolet\",\n//   \"model\": \"Corvette\",\n//   \"price\": 45000\n// }\n```\n\n## API\n\n### collectReducer\n\n```javascript\nconst reducerForCollection = collectReducer(reducerForSingleEntity, pathToKeyWithinAction)\n```\n\n`reducerForSingleEntity` should return undefined to remove the entity from the collection.\nOtherwise, the state it returns is added to the collection.\n\n`pathToKeyWithinAction` is the [path](https://lodash.com/docs/4.17.4#get) where the generated reducer looks for the collection key within dispatched actions.\n\n### collectSelector\n\nMost of the time `collectSelectors` is recommended.\n\n```javascript\nconst selectorForCollection = collectSelector(selectorForSingleEntity)\n```\n\n`selectorForSingleEntity` entity is a [selector](https://github.com/tayiorbeii/egghead.io_idiomatic_redux_course_notes/blob/master/10-Colocating_Selectors_with_Reducers.md) corresponding to `reducerForSingleEntity`, with is called like `selectorForSingleEntity(state, ...args)`.\n\n`selectorForCollection` is a generated selector corresponding to `reducerForCollection`, and is called liked `selectorForCollection(state, key, ...args)`.\n\n### collectSelectors\n\n```javascript\nconst selectorsForSingleEntity = {\n  selector1,\n  selector2\n}\n\n// Same as:\n// const selectorsForCollection = {\n//   selector1: collectSelector(selector1),\n//   selector2: collectSelector(selector2)\n// }\nconst selectorsForCollection = collectSelectors(selectorsForSingleEntity)\n```\n\nSimilar to `collectSelector`, except it takes an object containing one or more selectors.\n\n### collectAction\n\nMost of the time, `collectActions` is recommended.\n\n```javascript\nconst actionCreatorForCollection = collectionAction(actionCreatorForSingleEntity, pathToKeyWithinAction, optionalSelectorsForThunks)\n```\n\n`actionCreatorForSingleEntity` is an action creator with no knowledge of the collection,\nmost likely corresponding to `reducerForSingleEntity`.\n\n`pathToKeyWithinAction` is the [path](https://lodash.com/docs/4.17.4#get) where\nactions will be decorated with the collection key.\n\n`optionalSelectorsForThunks` is an optional parameter that is recursively passed as the third parameter to [thunks](https://github.com/gaearon/redux-thunk) created by `actionCreatorForSingleEntity`.\n\n### collectActions\n\n```javascript\nconst actionCreatorsForCollection = collectionActions(actionCreatorsForSingleEntity, pathToKeyWithinAction, optionalSelectorsForThunks)\n```\n\nSimilar to `collectAction`, but for an object containing multiple action creators.\n\n### bindSelector, bindSelectors, bindCollectedAction, and bindCollectedActions\n\n```javascript\nconst boundSelector = bindSelector(selectorForCollection, key)\nconst boundSelectors = bindSelector(selectorsForCollection, key)\nconst boundActionCreator = bindCollectedAction(actionCreatorForCollection, key)\nconst boundActionCreators = bindCollectedActions(actionCreatorsForCollection, key)\n```\n\nHelpers to bind the output of `collectSelector` and `collectActions` to key corresponding to a specific entity.\ne.g.:\n\n```javascript\nconst getJeepPrice = bindSelector(selectors.getPrice, \"1G6KD54Y73U255447\")\nconst setJeepPrice = bindCollectedAction(actions.setPrice, \"1G6KD54Y73U255447\")\n```\n\n## Immutability\n\nThe collections are maintained using `Immutable.js`.\nMaps created by `Immutable.Map` are properly serializable.\n`redux-collect` should handle state hydration and serialization properly.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcpnota%2Fredux-collect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcpnota%2Fredux-collect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcpnota%2Fredux-collect/lists"}