{"id":22539468,"url":"https://github.com/fkrasnowski/stateverse","last_synced_at":"2025-10-06T06:14:12.052Z","repository":{"id":40762830,"uuid":"274770630","full_name":"fkrasnowski/stateverse","owner":"fkrasnowski","description":"Async state manager - painless manager for async state changes and side effects","archived":false,"fork":false,"pushed_at":"2023-01-06T10:17:48.000Z","size":879,"stargazers_count":1,"open_issues_count":12,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-18T20:35:12.302Z","etag":null,"topics":["async","side-effects","state","state-management","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/fkrasnowski.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":"2020-06-24T21:13:03.000Z","updated_at":"2020-09-28T11:00:54.000Z","dependencies_parsed_at":"2023-02-05T21:01:11.420Z","dependency_job_id":null,"html_url":"https://github.com/fkrasnowski/stateverse","commit_stats":null,"previous_names":["fkrasnowski/fxer"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fkrasnowski/stateverse","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fkrasnowski%2Fstateverse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fkrasnowski%2Fstateverse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fkrasnowski%2Fstateverse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fkrasnowski%2Fstateverse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fkrasnowski","download_url":"https://codeload.github.com/fkrasnowski/stateverse/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fkrasnowski%2Fstateverse/sbom","scorecard":{"id":402283,"data":{"date":"2025-08-11","repo":{"name":"github.com/fkrasnowski/stateverse","commit":"f8dec0268978e91f2a7973efd351818ec0b0effe"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/26 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":"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":"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":"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":"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":"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":"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":"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":"Vulnerabilities","score":0,"reason":"30 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj","Warn: Project is vulnerable to: GHSA-896r-f27r-55mw","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","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-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp","Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7","Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q","Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh"],"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-18T20:20:56.506Z","repository_id":40762830,"created_at":"2025-08-18T20:20:56.507Z","updated_at":"2025-08-18T20:20:56.507Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278566503,"owners_count":26007780,"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-06T02:00:05.630Z","response_time":65,"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":["async","side-effects","state","state-management","typescript"],"created_at":"2024-12-07T12:07:03.702Z","updated_at":"2025-10-06T06:14:12.033Z","avatar_url":"https://github.com/fkrasnowski.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# stateverse 👽\n\nAsync state manager - painless manager for async state changes and side effects\n\n## Installation\n\n```sh\n# npm\nnpm i --save stateverse\n\n# yarn\nyarn add stateverse\n```\n\n## Features\n\n- 👣 Minimalistic API\n- 👨‍👩‍👧‍👦 Framework agnostic\n- 🦾 TypeScript support\n\n## Example\n\n```js\nconst counter = createStore(0)\n  .addReducers({\n    add: (state, v) =\u003e state + v,\n    sub: (state, v) =\u003e state - v,\n    reset: () =\u003e 0,\n  })\n  .addEffects({\n    countDownFx: async (reducers, cleanup) =\u003e {\n      const interval = setInterval(() =\u003e {\n        if (counter.state \u003e 0) reducers.inc();\n        else clearInterval(interval);\n      }, 1000);\n      cleanup(() =\u003e {\n        clearInterval(interval);\n      });\n    },\n  });\n\ncounter.watch((count) =\u003e console.log(`counter: ${count}`));\n\ncounter.actions.add.watch((v) =\u003e console.log(`add: ${v}`));\n\ncounter.actions.sub.watch((v) =\u003e console.log(`substract: ${v}`));\n\ncounter.actions.add(10);\n//add: 10\n//counter: 10\ncounter.actions.sub(5);\n// substract: 5\n// counter: 5\ncounter.actions.countDownFx();\n// substract: 1\n// counter: 4\n// substract: 1\n// counter: 3\n//...\n```\n\n## Core concepts\n\n### Store\n\nIt's an object that holds state. You can define many stores. To define one use `createStore` factory:\n\n```js\nimport { createStore } from 'stateverse';\n\nconst store = createStore({ state });\n```\n\n### Action\n\n**Action** is either `reducer` or `effect`. Actions represent an intention to change `state`. `actions` can be attached to the store. Call action from actions property of store:\n\n```js\nstore.actions.addData({ login: 'fkrasnowski', password: '☜(ﾟヮﾟ☜)' });\n```\n\n### Reducer\n\n**Reducer** is a function that takes state (and additional values) and returns a new state that replaces the old one. Reducers must be `pure`. To define reducers use `.addReducers` method:\n\n```js\nstore.addReducers({\n  addData: (state, data) =\u003e ({ ...state, data }),\n});\n```\n\n### Effect\n\n**Effect** is a container for asynchronous state changes. `Effect` has access to all `reducers` of the `store`. Store runs one effect at the same time. If another `action` is triggered before effect finish, the effect is being canceled and the cleanup function is executed. To define effect use `.addEffects` method:\n\n```js\nstore.addEffects({\n  loadDataFx: async (reducers, cleanup, id) =\u003e {\n    reducers.setLoading(true);\n    const data = await fetchData(id);\n    reducers.addData(data);\n    reducers.setLoading(false);\n  },\n});\n```\n\n### Cleanup\n\nSome `effects` of course demand `cleanup`. To add so provide your `cleanup` function as an argument for `cleanup`. The `cleanup` function is attached asynchronously so implement it as early as possible:\n\n```js\nconst countDownFx = async (reducers, cleanup) =\u003e {\n      const interval = setInterval(() =\u003e {\n        if (counter.state \u003e 0) reducers.inc();\n        else clearInterval(interval);\n      }, 1000);\n      cleanup(() =\u003e {\n        clearInterval(interval);\n      });\n    },\n\n```\n\n### Watchable\n\n**Watchable** is a function that can be watched. It means you can attach a `callback` to be triggered while function is called. `Actions` are watchable by default. You can create a `watchable` from function like so:\n\n```js\nimport { watchable } from 'stateverse';\n\nconst watchableFn = watchable((v) =\u003e v + 👀);\n  watchableFn.watch((...args) =\u003e console.log('watchout!',...args)));\n  watchableFn('💥') //Logs: wachout! 💥\n```\n\n### Inner state ⚠\n\nIt's really **important** to understand this idea. **Stateverse** assumes that `effects` break the integrity of the state in general. That's why effects are _`auto-canceled`_ while new `action` is being invoked. The new `action` does not operate on `state` from within canceled effect. It takes the `state` from **before** the effect has affected it! This is the so-called **inner state** - an unexposed state accessible **only** by reducers that are protected from inconstant changes\n\n## API\n\n#### `createStore\u003cT\u003e(initialState: T): stateverse.Store\u003cT\u003e`\n\nReturns store that holds state of type `T`\n\n#### `.state`\n\nReturns current state\n\n#### `.watch(callback: (state: T) =\u003e any)`\n\nAttaches a `callback` function to observe state changes\n\n#### `.unwatch(callback: (state: T) =\u003e any)`\n\nDetaches a callback function from observation\n\n```js\nconst callbackFn = fn.spy();\nstore.watch(callbackFn); //Attaches: callbackFn\n//...\nstore.unwatch(callbackFn); //Detaches: callbackFn\n```\n\n#### `.actions.\u003caction-name\u003e.watch(callback: (...values: any) =\u003e any)`\n\nTriggers `callback` on action call with `values` (arguments) provided to the action\n\n#### `.map\u003cT, S\u003e(mapFn: (state: T) =\u003e S): stateverse.WatchStore\u003cT, S\u003e`\n\nA map function to map state and watch only for particular state changes\n\n```js\narrayStore.map((state) =\u003e state[0]).watch(console.log);\n```\n\n#### `Reducer\u003cT\u003e = (state: T, ...values: any) =\u003e T`\n\nA pure function that takes state as first argument and additional values provided on action call\n\n#### `Effect = (reducers: Actions, cleanup: (cleanupFn: Cleanup) =\u003e void, ...values: any) =\u003e Promise\u003cvoid\u003e`\n\nA function returning `Promise` (`async function`)\n\n#### `.addReducers(reducers: Reducers\u003cT\u003e)`\n\nAdds `reducers` to store\n\n#### `.addEffects(effects: Effects)`\n\nAdds `effects` to store\n\n#### `watchable(fn: Function): watchableFn`\n\nCreates function with additional methods `.watch` and `.unwatch`\n\n## Complementary packages\n\n- **React:** [stateverse-react](https://github.com/fkrasnowski/stateverse-react)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffkrasnowski%2Fstateverse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffkrasnowski%2Fstateverse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffkrasnowski%2Fstateverse/lists"}