{"id":15297087,"url":"https://github.com/75lb/fsm-base","last_synced_at":"2025-06-12T16:33:10.410Z","repository":{"id":57242467,"uuid":"44926679","full_name":"75lb/fsm-base","owner":"75lb","description":"Finite State Machine for use as a base class or mix-in","archived":false,"fork":false,"pushed_at":"2024-07-06T13:32:41.000Z","size":231,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T13:12:30.254Z","etag":null,"topics":["es6","finite-state-machine","isomorphic","javascript-library","load-anywhere","nodejs"],"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/75lb.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":"2015-10-25T19:48:38.000Z","updated_at":"2024-07-06T13:32:44.000Z","dependencies_parsed_at":"2024-06-19T05:22:23.152Z","dependency_job_id":"e8bc2712-e842-4011-9233-e0242a61cbcb","html_url":"https://github.com/75lb/fsm-base","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/75lb%2Ffsm-base","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/75lb%2Ffsm-base/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/75lb%2Ffsm-base/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/75lb%2Ffsm-base/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/75lb","download_url":"https://codeload.github.com/75lb/fsm-base/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248794565,"owners_count":21162614,"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","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":["es6","finite-state-machine","isomorphic","javascript-library","load-anywhere","nodejs"],"created_at":"2024-09-30T19:15:03.251Z","updated_at":"2025-04-13T23:00:26.136Z","avatar_url":"https://github.com/75lb.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![view on npm](https://badgen.net/npm/v/fsm-base)](https://www.npmjs.org/package/fsm-base)\n[![npm module downloads](https://badgen.net/npm/dt/fsm-base)](https://www.npmjs.org/package/fsm-base)\n[![Gihub repo dependents](https://badgen.net/github/dependents-repo/75lb/fsm-base)](https://github.com/75lb/fsm-base/network/dependents?dependent_type=REPOSITORY)\n[![Gihub package dependents](https://badgen.net/github/dependents-pkg/75lb/fsm-base)](https://github.com/75lb/fsm-base/network/dependents?dependent_type=PACKAGE)\n[![Node.js CI](https://github.com/75lb/fsm-base/actions/workflows/node.js.yml/badge.svg)](https://github.com/75lb/fsm-base/actions/workflows/node.js.yml)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](https://github.com/feross/standard)\n\n# fsm-base\n\nFinite state machine.\n\nEither mix it into an existing object:\n\n```js\nimport StateMachine from 'fsm-base'\n\nconst device = {}\nStateMachine.mixInto(device)\n\ndevice._initStateMachine('offline', [\n  { from: 'offline', to: 'connecting' },\n  { from: 'connecting', to: 'online' },\n  { from: ['connecting', 'online'], to: 'offline' }\n])\n\ndevice.onStateChange = function (state, prevState) {\n  console.log(state, prevState)\n}\n\ndevice.state = 'connecting'\ndevice.state = 'connecting' // should not trigger events again\ndevice.state = 'online'\ndevice.state = 'offline' // valid state move\n```\n\n..or define a class which extends it:\n\n```js\nclass Device extends StateMachine {}\n\nconst device = new Device()\ndevice._initStateMachine('offline', [\n  { from: 'offline', to: 'connecting' },\n  { from: 'connecting', to: 'online' },\n  { from: ['connecting', 'online'], to: 'offline' }\n])\n\ndevice.onStateChange = function (state, prevState) {\n  console.log(state, prevState)\n}\n\ndevice.state = 'connecting'\n// etc\n```\n\n..or mix it into an existing class that does not `extend` fsm-base.\n\n```js\nclass Device {}\nStateMachine.mixInto(Device)\n\nconst device = new Device()\ndevice._initStateMachine('offline', [\n  { from: 'offline', to: 'connecting' },\n  { from: 'connecting', to: 'online' },\n  { from: ['connecting', 'online'], to: 'offline' }\n])\n\ndevice.onStateChange = function (state, prevState) {\n  console.log(state, prevState)\n}\n\ndevice.state = 'connecting'\n//etc\n```\n\nSee the [API Documentation](https://github.com/75lb/fsm-base/tree/master/docs/api.md) for more information.\n\n* * *\n\n\u0026copy; 2015-24 Lloyd Brookes \\\u003c75pound@gmail.com\\\u003e. Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F75lb%2Ffsm-base","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F75lb%2Ffsm-base","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F75lb%2Ffsm-base/lists"}