{"id":15693556,"url":"https://github.com/shannonmoeller/deduce","last_synced_at":"2025-10-08T04:50:16.930Z","repository":{"id":66097208,"uuid":"56255380","full_name":"shannonmoeller/deduce","owner":"shannonmoeller","description":"Ridiculously easy JavaScript state containers with action methods.","archived":false,"fork":false,"pushed_at":"2018-02-15T23:28:23.000Z","size":163,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-09-23T23:02:00.269Z","etag":null,"topics":["actions","flux","nodejs","reducers","redux","state"],"latest_commit_sha":null,"homepage":"http://npm.im/deduce","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/shannonmoeller.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-04-14T17:04:02.000Z","updated_at":"2018-11-01T02:13:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"7a3726a0-7d4a-4c12-b468-695d2e717ef4","html_url":"https://github.com/shannonmoeller/deduce","commit_stats":{"total_commits":42,"total_committers":2,"mean_commits":21.0,"dds":"0.023809523809523836","last_synced_commit":"3327568fd1efb9d80a4513177ea9a6b9ee30752f"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/shannonmoeller/deduce","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shannonmoeller%2Fdeduce","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shannonmoeller%2Fdeduce/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shannonmoeller%2Fdeduce/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shannonmoeller%2Fdeduce/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shannonmoeller","download_url":"https://codeload.github.com/shannonmoeller/deduce/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shannonmoeller%2Fdeduce/sbom","scorecard":{"id":816084,"data":{"date":"2025-08-11","repo":{"name":"github.com/shannonmoeller/deduce","commit":"3327568fd1efb9d80a4513177ea9a6b9ee30752f"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"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":"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":"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":"Code-Review","score":0,"reason":"Found 0/30 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":"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":"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":"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":"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":"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":"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":"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":"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"}},{"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":"Vulnerabilities","score":0,"reason":"74 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-wrw9-m778-g6mc","Warn: Project is vulnerable to: GHSA-pp7h-53gx-mx7r","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-cwfw-4gq5-mrqx","Warn: Project is vulnerable to: GHSA-g95f-p29q-9xw4","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-x9w5-v3q2-3rhw","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-rq8g-5pc5-wrhr","Warn: Project is vulnerable to: GHSA-h6ch-v84p-w6p9","Warn: Project is vulnerable to: GHSA-vh7m-p724-62c2","Warn: Project is vulnerable to: GHSA-r9p9-mrjm-926w","Warn: Project is vulnerable to: GHSA-434g-2637-qmqr","Warn: Project is vulnerable to: GHSA-49q7-c7j4-3p7m","Warn: Project is vulnerable to: GHSA-977x-g7h5-7qgw","Warn: Project is vulnerable to: GHSA-f7q4-pwc6-w24p","Warn: Project is vulnerable to: GHSA-fc9h-whq2-v747","Warn: Project is vulnerable to: GHSA-vjh7-7g9h-fjfh","Warn: Project is vulnerable to: GHSA-qrmc-fj45-qfc2","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-q42p-pg8m-cqh6","Warn: Project is vulnerable to: GHSA-w457-6q6x-cgp9","Warn: Project is vulnerable to: GHSA-62gr-4qp9-h98f","Warn: Project is vulnerable to: GHSA-f52g-6jhx-586p","Warn: Project is vulnerable to: GHSA-2cf5-4w76-r9qv","Warn: Project is vulnerable to: GHSA-3cqr-58rm-57f8","Warn: Project is vulnerable to: GHSA-g9r4-xpmj-mj65","Warn: Project is vulnerable to: GHSA-q2c6-c6pm-g3gh","Warn: Project is vulnerable to: GHSA-765h-qjxv-5f44","Warn: Project is vulnerable to: GHSA-f2jv-r9rf-7988","Warn: Project is vulnerable to: GHSA-44pw-h2cw-w3vq","Warn: Project is vulnerable to: GHSA-jp4x-w63m-7wgm","Warn: Project is vulnerable to: GHSA-c429-5p7v-vgjp","Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj","Warn: Project is vulnerable to: GHSA-8g7p-74h8-hg48","Warn: Project is vulnerable to: GHSA-pc5p-h8pf-mvwp","Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37","Warn: Project is vulnerable to: GHSA-2pr6-76vf-7546","Warn: Project is vulnerable to: GHSA-8j8c-7jfh-h6hx","Warn: Project is vulnerable to: GHSA-896r-f27r-55mw","Warn: Project is vulnerable to: GHSA-fvqr-27wr-82fm","Warn: Project is vulnerable to: GHSA-4xc9-xhrj-v574","Warn: Project is vulnerable to: GHSA-x5rq-j2xg-h7qm","Warn: Project is vulnerable to: GHSA-jf85-cpcp-j695","Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-4xcv-9jjx-gfj3","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-h7cp-r72f-jxh6","Warn: Project is vulnerable to: GHSA-v62p-rq8g-8h59","Warn: Project is vulnerable to: GHSA-c2gp-86p4-5935","Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp","Warn: Project is vulnerable to: GHSA-6g33-f262-xjp4","Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6","Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm","Warn: Project is vulnerable to: GHSA-x6fg-f45m-jf5q","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-jv35-xqg7-f92r","Warn: Project is vulnerable to: GHSA-g4rg-993r-mgx7","Warn: Project is vulnerable to: GHSA-2m39-62fm-q8r3","Warn: Project is vulnerable to: GHSA-mf6x-7mm4-x2g7","Warn: Project is vulnerable to: GHSA-52f5-9888-hmc6","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q","Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh","Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-23T14:18:03.712Z","repository_id":66097208,"created_at":"2025-08-23T14:18:03.712Z","updated_at":"2025-08-23T14:18:03.712Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278891744,"owners_count":26063855,"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":["actions","flux","nodejs","reducers","redux","state"],"created_at":"2024-10-03T18:45:32.177Z","updated_at":"2025-10-08T04:50:16.910Z","avatar_url":"https://github.com/shannonmoeller.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# deduce\n\n[![NPM version][npm-img]][npm-url]\n[![Downloads][downloads-img]][npm-url]\n[![Build Status][travis-img]][travis-url]\n[![Coverage Status][coveralls-img]][coveralls-url]\n[![Tip][amazon-img]][amazon-url]\n\nRidiculously easy JavaScript state containers with reducer methods. Like [Redux](https://github.com/reactjs/redux) without all of the boilerplate.\n\n## Install\n\n```\nnpm install --save deduce\n```\n\n## Usage\n\n```js\n// reducers.js\n\nexport function increment(state, val = 1) {\n    return state + val;\n}\n\nexport function decrement(state, val = 1) {\n    return increment(state, -val);\n}\n\n// store.js\n\nimport deduce from 'deduce';\nimport * as reducers from './reducers';\n\nconst store = deduce(1, reducers);\n\nstore.addListener(() =\u003e {\n    console.log(store.state);\n});\n\nstore.increment();  // -\u003e 2\nstore.increment(2); // -\u003e 4\nstore.decrement();  // -\u003e 3\nstore.decrement(2); // -\u003e 1\n```\n\n## API\n\n### deduce(initialState, reducers) : Store\n\n- `initialState` `{*}`\n- `reducers` `{Object\u003cString,Function\u003e}`\n\n### Store\n\n#### .state\n\nCurrent state of the store.\n\n```js\nconst store = deduce({ foo: 1 });\n\nconsole.log(store.state); // -\u003e { foo: 1 }\n```\n\n#### .addReducers(reducers): Store\n\n- `reducers` `{Object\u003cString,Function\u003e}`\n\nRegisters reducers to modify the state. Chainable.\n\n```js\nstore.addReducers({\n    increment(state, val) {\n        return {\n            ...state,\n            foo: state.foo + val,\n        };\n    },\n});\n```\n\n#### .addReducersFor(property, reducers): Store\n\n- `property` `{String}`\n- `reducers` `{Object\u003cString,Function\u003e}`\n\nRegisters reducers to modify a specific state property. Chainable.\n\n```js\nstore.addReducersFor('foo', {\n    increment(state, val) {\n        return state + val;\n    },\n});\n```\n\n#### .addListener(callback): Function\n\n- `callback` `{Function}`\n\nAdds a listener to be called any time the state is updated. Returns a function to remove the listener.\n\n```js\nconst removeListener = store.addListener(() =\u003e {\n    console.log(store.state);\n});\n\nstore.increment();\n```\n\n## Why?\n\nThe typical Redux patterns entail a lot of boilerplate. The documented and accepted [patterns for reducing boilerplate](https://github.com/reactjs/redux/blob/7fe001c/docs/recipes/ReducingBoilerplate.md) really just swap one kind for another:\n\n### Redux Example\n\nConsider the following Redux example that creates a store with two numbers: `foo` which may be incremented and `bar` which may be decremented.\n\n```js\n// foo\n\nconst FOO_INCREMENT = 'FOO_INCREMENT';\n\nconst fooInitial = 0;\n\nconst fooReducers = {\n    [FOO_INCREMENT]: (state = fooInitial, action) {\n        return state + action.payload;\n    }\n};\n\nfunction foo(state = {}, action) {\n    if (action.type in fooReducers) {\n        return fooReducers[action.type](state, action);\n    }\n\n    return state;\n}\n\nfunction createFooIncrementAction(payload) {\n    return {\n        type: FOO_INCREMENT,\n        payload\n    };\n}\n\n// bar\n\nconst BAR_DECREMENT = 'BAR_DECREMENT';\n\nconst barInitial = 0;\n\nconst barReducers = {\n    [BAR_DECREMENT]: (state = barInitial, action) {\n        return state - action.payload;\n    }\n};\n\nfunction bar(state, action) {\n    if (action.type in barReducers) {\n        return barReducers[action.type](state, action);\n    }\n\n    return state;\n}\n\nfunction createBarDecrementAction(payload) {\n    return {\n        type: BAR_DECREMENT,\n        payload\n    };\n}\n\n// store\n\nimport { createStore, combineReducers } from 'redux';\n\nconst reducer = combineReducers({ foo, bar });\nconst store = createStore(reducer, {});\n\n// application\n\nstore.dispatch(createFooIncrementAction(1));\nstore.dispatch(createBarDecrementAction(1));\n\nconsole.log(store.getState());\n// {\n//   foo: 1,\n//   bar: -1\n// }\n```\n\nSplit that up into modules and you can see how new-comers could easily be overwhelmed when the underlying principles are beautifully clean and simple.\n\n### Deduce Example\n\nCompare [the above](#redux-example) with this `deduce` example that does the same thing:\n\n```js\n// foo\n\nconst fooInitial = 0;\n\nconst fooReducers = {\n    incrementFoo(state = fooInitial, val) {\n        return state + val;\n    }\n};\n\n// bar\n\nconst barInitial = 0;\n\nconst barReducers = {\n    decrementBar(state = barInitial, val) {\n        return state - val;\n    }\n};\n\n// store\n\nimport deduce from 'deduce';\n\nconst store = deduce()\n    .addReducersFor('foo', fooReducers)\n    .addReducersFor('bar', barReducers);\n\n// application\n\nstore.incrementFoo(1);\nstore.decrementBar(1);\n\nconsole.log(store.state);\n// {\n//   foo: 1,\n//   bar: -1\n// }\n```\n\n## Contribute\n\nStandards for this project, including tests, code coverage, and semantics are enforced with a build tool. Pull requests must include passing tests with 100% code coverage and no linting errors.\n\n### Test\n\n    $ npm test\n\n----\n\nMIT © [Shannon Moeller](http://shannonmoeller.com)\n\n[amazon-img]:    https://img.shields.io/badge/amazon-tip_jar-yellow.svg?style=flat-square\n[amazon-url]:    https://www.amazon.com/gp/registry/wishlist/1VQM9ID04YPC5?sort=universal-price\n[coveralls-img]: http://img.shields.io/coveralls/shannonmoeller/deduce/master.svg?style=flat-square\n[coveralls-url]: https://coveralls.io/r/shannonmoeller/deduce\n[downloads-img]: http://img.shields.io/npm/dm/deduce.svg?style=flat-square\n[npm-img]:       http://img.shields.io/npm/v/deduce.svg?style=flat-square\n[npm-url]:       https://npmjs.org/package/deduce\n[travis-img]:    http://img.shields.io/travis/shannonmoeller/deduce/master.svg?style=flat-square\n[travis-url]:    https://travis-ci.org/shannonmoeller/deduce\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshannonmoeller%2Fdeduce","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshannonmoeller%2Fdeduce","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshannonmoeller%2Fdeduce/lists"}