{"id":33180933,"url":"https://github.com/steelbreeze/state","last_synced_at":"2025-11-20T21:04:40.108Z","repository":{"id":37733915,"uuid":"94681446","full_name":"steelbreeze/state","owner":"steelbreeze","description":"Hierarchical finite state machine for TypeScript and JavaScript","archived":false,"fork":false,"pushed_at":"2024-04-14T06:18:02.000Z","size":1997,"stargazers_count":188,"open_issues_count":0,"forks_count":21,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-10-01T02:24:25.448Z","etag":null,"topics":["finite","finite-state-machine","javascript","machine","orthogonal","pseudostate","region","state","typescript"],"latest_commit_sha":null,"homepage":"https://steelbreeze.net/state","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/steelbreeze.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":"2017-06-18T10:55:50.000Z","updated_at":"2025-09-23T19:57:14.000Z","dependencies_parsed_at":"2024-06-20T22:09:14.652Z","dependency_job_id":null,"html_url":"https://github.com/steelbreeze/state","commit_stats":{"total_commits":433,"total_committers":3,"mean_commits":"144.33333333333334","dds":"0.018475750577367167","last_synced_commit":"7f47369e6f6229a056bb83a4432457df2194d340"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"purl":"pkg:github/steelbreeze/state","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steelbreeze%2Fstate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steelbreeze%2Fstate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steelbreeze%2Fstate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steelbreeze%2Fstate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/steelbreeze","download_url":"https://codeload.github.com/steelbreeze/state/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/steelbreeze%2Fstate/sbom","scorecard":{"id":850200,"data":{"date":"2025-08-11","repo":{"name":"github.com/steelbreeze/state","commit":"2bc9fa4996e6886cadc6e0da7f96d7a3042fd3b8"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.3,"checks":[{"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":"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":"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":"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":"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":"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":"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":"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":"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":"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":"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":4,"reason":"6 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","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-76p7-773f-r4q5","Warn: Project is vulnerable to: GHSA-4vvj-4cpr-p986"],"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-23T22:18:21.504Z","repository_id":37733915,"created_at":"2025-08-23T22:18:21.504Z","updated_at":"2025-08-23T22:18:21.504Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":285512073,"owners_count":27184296,"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-11-20T02:00:05.334Z","response_time":54,"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":["finite","finite-state-machine","javascript","machine","orthogonal","pseudostate","region","state","typescript"],"created_at":"2025-11-16T04:00:23.294Z","updated_at":"2025-11-20T21:04:40.103Z","avatar_url":"https://github.com/steelbreeze.png","language":"JavaScript","funding_links":[],"categories":["Libraries"],"sub_categories":["JavaScript"],"readme":"# state\nExecutable finite state machine for TypeScript and JavaScript.\n\nIf you like @steelbreeze/state, please star it...\n\n[![NPM Version][npm-image]][npm-url]\n[![NPM Downloads][downloads-image]][npm-url]\n[![Build Status](https://travis-ci.org/steelbreeze/state.svg?branch=master)](https://travis-ci.org/steelbreeze/state)\n[![Maintainability](https://api.codeclimate.com/v1/badges/ba16b2f2be9016842326/maintainability)](https://codeclimate.com/github/steelbreeze/state/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/ba16b2f2be9016842326/test_coverage)](https://codeclimate.com/github/steelbreeze/state/test_coverage)\n\n\u003e **Note:** v8 is now live and contains breaking changes but offers a further simplified code base performance improvements. See the [release notes](RELEASES.md) for more information.\n\u003e\n\u003e **Warning:** v8 does not yet contain any support for serialization due to the challanges brought by the introduction of deferred events which are cached within the state machine instance alongside the active state configuration. \n\n## Install\n```shell\nnpm i @steelbreeze/state\n```\n\n## Usage\nThe API is broken up into two distinct parts:\n1. A set of classes that represent a state machine model ([State](https://steelbreeze.net/state/api/v8/classes/state.html), [PseudoState](https://steelbreeze.net/state/api/v8/classes/pseudostate.html), [Region](https://steelbreeze.net/state/api/v8/classes/region.html), etc.);\n2. An class managing the active state configuration of a state machine instance at runtime ([Instance](https://steelbreeze.net/state/api/v8/classes/instance.html)). \n\nTogether, they enable multiple instances of the same state machine model.\n\nThe full API reference can be found [here](https://steelbreeze.net/state/api/v8).\n\n### TypeScript\n```typescript\nimport * as state from \"@steelbreeze/state\";\n\n// create event class that a transition will respond to\nclass MyEvent {\n\tpublic constructor(public fieldA: string, public fieldB: number) { }\n\n\tpublic toString(): string {\n\t\treturn JSON.stringify(this);\n\t}\n}\n\n// log state entry, exit and trigger event evaluation\nstate.log.add(message =\u003e console.info(message), state.log.Entry | state.log.Exit | state.log.Evaluate);\n\n// create the state machine model elements\nconst model = new state.State(\"model\");\nconst initial = new state.PseudoState(\"initial\", model, state.PseudoStateKind.Initial);\nconst stateA = new state.State(\"stateA\", model);\nconst stateB = new state.State(\"stateB\", model);\n\n// create the transition from initial pseudo state to stateA\ninitial.to(stateA);\n\n// create a transtion from stateA to stateB a for events of type MyEvent with a guard condition\nstateA.on(MyEvent).when(myEvent =\u003e myEvent.fieldB \u003e 2).to(stateB);\n\n// create an instance of the state machine model\nlet instance = new state.Instance(\"instance\", model);\n\n// send the machine events for evaluation\ninstance.evaluate(new MyEvent(\"test\", 1));\ninstance.evaluate(new MyEvent(\"test\", 3));\n```\n### JavaScript (ECMAScript 2015)\n```javascript\nvar state = require(\"@steelbreeze/state\");\n\n// create event class that a transition will respond to\nclass MyEvent {\n\tconstructor(fieldA, fieldB) { this.fieldA = fieldA; this.fieldB = fieldB; }\n\n\ttoString() { return JSON.stringify(this); }\n}\n\n// log state entry, exit and trigger event evaluation\nstate.log.add(message =\u003e console.info(message), state.log.Entry | state.log.Exit | state.log.Evaluate);\n\n// create the state machine model elements\nconst model = new state.State(\"model\");\nconst initial = new state.PseudoState(\"initial\", model, state.PseudoStateKind.Initial);\nconst stateA = new state.State(\"stateA\", model);\nconst stateB = new state.State(\"stateB\", model);\n\n// create the transition from initial pseudo state to stateA\ninitial.to(stateA);\n\n// create a transtion from stateA to stateB a for events of type MyEvent with a guard condition\nstateA.on(MyEvent).when(myEvent =\u003e myEvent.fieldB \u003e 2).to(stateB);\n\n// create an instance of the state machine model\nlet instance = new state.Instance(\"instance\", model);\n\n// send the machine events for evaluation\ninstance.evaluate(new MyEvent(\"test\", 1));\ninstance.evaluate(new MyEvent(\"test\", 3));\n```\n### Output\nThe output of the above code will be:\n```shell\ninstance enter model\ninstance enter model.default\ninstance enter model.default.initial\ninstance leave model.default.initial\ninstance enter model.default.stateA\ninstance evaluate {\"fieldA\":\"test\",\"fieldB\":1}\ninstance evaluate {\"fieldA\":\"test\",\"fieldB\":3}\ninstance leave model.default.stateA\ninstance enter model.default.stateB\n```\n\u003e Note that in the example above, a *default region* is inserted as a child of ```model``` and parent of ```initial```, ```stateA``` and ```stateB```; the name of default regions copy their parent state hence seeing ```model.model``` in the output above. \n## License\nMIT License\n\nCopyright (c) 2022 David Morris\n\n[npm-image]: https://img.shields.io/npm/v/@steelbreeze/state.svg\n[npm-url]:       https://www.npmjs.com/package/@steelbreeze/state\n[downloads-image]: https://img.shields.io/npm/dm/@steelbreeze/state.svg\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsteelbreeze%2Fstate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsteelbreeze%2Fstate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsteelbreeze%2Fstate/lists"}