{"id":13457747,"url":"https://github.com/oldj/easy-fsm","last_synced_at":"2025-05-03T14:31:05.810Z","repository":{"id":57218435,"uuid":"130339979","full_name":"oldj/easy-fsm","owner":"oldj","description":"An easy-to-use finite state machine system for JavaScript.","archived":false,"fork":false,"pushed_at":"2024-06-06T13:43:14.000Z","size":89,"stargazers_count":13,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-30T03:18:29.451Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/oldj.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":"2018-04-20T09:22:42.000Z","updated_at":"2024-07-31T15:11:47.000Z","dependencies_parsed_at":"2024-03-23T17:28:51.441Z","dependency_job_id":"1628511a-d3e8-447a-b66b-3ec0069935c9","html_url":"https://github.com/oldj/easy-fsm","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oldj%2Feasy-fsm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oldj%2Feasy-fsm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oldj%2Feasy-fsm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oldj%2Feasy-fsm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oldj","download_url":"https://codeload.github.com/oldj/easy-fsm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252203186,"owners_count":21710903,"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":[],"created_at":"2024-07-31T09:00:35.460Z","updated_at":"2025-05-03T14:31:05.248Z","avatar_url":"https://github.com/oldj.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# easy-fsm\n\nAn easy-to-use finite state machine system for JavaScript.\n\n## install\n\n```bash\nnpm install easy-fsm\n```\n\n## usage\n\n```TypeScript\nimport EasyFSM from 'easy-fsm'\n\nlet fsm = new EasyFSM({\n  initial: 'init',\n  states: {\n    init: {\n      on: {\n        loaded: 'ready'\n      }\n    },\n    ready: {}\n  }\n})\n\nconsole.log(fsm.getState()) // init\nawait fsm.fire('loaded')\nconsole.log(fsm.getState()) // ready\n```\n\n## APIs\n\nYou can use `new EasyFSM(options)` to create a finite state machine.\n\n- **send(event)**\n\nSend an event on current state.\n\n- **sendAndWait(event)**\n\nSend an event on current state and wait for all listeners to finish.\n\n- **canSend(event)**\n\nDetect if the specified `event` can be sent.\n\n- **[getter] state**\n\nGet the current state.\n\n- **[getter] previous_state**\n\nGet the previous state.\n\n- **onEnter(state, callback)**\n\nExecute `callback` when entering `state`.\n\n- **onLeave(state, callback)**\n\nExecute `callback` when leaving `state`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foldj%2Feasy-fsm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foldj%2Feasy-fsm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foldj%2Feasy-fsm/lists"}