{"id":28559147,"url":"https://github.com/toastdriven/evstate","last_synced_at":"2025-06-10T08:36:18.967Z","repository":{"id":57701154,"uuid":"498182992","full_name":"toastdriven/evstate","owner":"toastdriven","description":"Event-based finite state machines","archived":false,"fork":false,"pushed_at":"2022-06-02T06:43:21.000Z","size":26,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-07T16:54:56.728Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/toastdriven.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":"2022-05-31T04:16:24.000Z","updated_at":"2024-12-07T13:26:10.000Z","dependencies_parsed_at":"2022-08-29T04:31:34.883Z","dependency_job_id":null,"html_url":"https://github.com/toastdriven/evstate","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toastdriven%2Fevstate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toastdriven%2Fevstate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toastdriven%2Fevstate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toastdriven%2Fevstate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/toastdriven","download_url":"https://codeload.github.com/toastdriven/evstate/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toastdriven%2Fevstate/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259039630,"owners_count":22796878,"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":"2025-06-10T08:36:08.682Z","updated_at":"2025-06-10T08:36:18.949Z","avatar_url":"https://github.com/toastdriven.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `evstate`\n\nEvent-based finite state machines.\n\n\n## Quickstart\n\n```js\nimport FSM from 'evstate';\n\nconst publishWorkflow = new FSM(\n  {\n    'draft': ['inReview'],\n    'inReview': ['changesNeeded', 'approved'],\n    'changesNeeded': ['inReview', 'approved'],\n    'approved': ['draft', 'scheduled', 'published'],\n    'scheduled': ['draft', 'published'],\n    'published': null,\n  },\n  'draft'\n);\n\n// Add (optional) behavior when state changes happen.\npublishWorkflow\n  .on(FSM.ANY, (obj) =\u003e {\n    obj.state = publishWorkflow.currentState;\n  })\n  .on('inReview', (obj) =\u003e {\n    // Send a notification to a reviewer.\n    emailReviewer(obj);\n  })\n  .on('changesNeeded', (obj) =\u003e {\n    // Send a notification to the author to make changes.\n    emailAuthor(obj);\n  })\n  .on('published', (obj) =\u003e {\n    obj.publishDate = new Date();\n  })\n  .onError((msg) =\u003e {\n    console.log(msg);\n  });\n\n// Create a draft.\n// This is a plain old Object, but could be a Model or anything else!\nconst firstPost = {\n  title: 'Hello World!',\n  content: 'This is my very first PASTE to the website!',\n  state: publishWorkflow.currentState,\n  created: new Date(),\n);\n\n// Get a reviewer to look.\npublishWorkflow.emit('inReview', firstPost);\n\n// Oops! There was a typo!\npublishWorkflow.emit('changesNeeded', firstPost);\n\n// The author fixes it.\nfirstPost.content = 'This is my very first post to the website!';\npublishWorkflow.emit('inReview', firstPost);\n\n// Reviewer approves it!\npublishWorkflow.emit('approved', firstPost);\n\n// Somebody makes a mistake \u0026 tries to put it back in review!\n// This logs a console error \u0026 DOES NOT save the change to the post!\npublishWorkflow.emit('inReview', firstPost);\n\n// Editor checks the list of stories ready to go...\n// ...and says it's time to publish the first one!\npublishWorkflow.emit('published', firstPost);\n```\n\n\n## Installation\n\n`$ npm install evstate`\n\n\n## Requirements\n\n* ES6 (or similar translation/polyfill)\n\n\n## Tests\n\n`$ npm test`\n\n\n## Docs\n\n`$ jsdoc -r -d ~/Desktop/out --package package.json --readme README.md src`\n\n\n## License\n\nNew BSD\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoastdriven%2Fevstate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftoastdriven%2Fevstate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoastdriven%2Fevstate/lists"}