{"id":18096208,"url":"https://github.com/bredele/mood","last_synced_at":"2025-04-13T09:32:34.528Z","repository":{"id":15126900,"uuid":"17853967","full_name":"bredele/mood","owner":"bredele","description":":speak_no_evil: Give some mood to your code with a finite state machine","archived":false,"fork":false,"pushed_at":"2020-03-10T22:27:11.000Z","size":104,"stargazers_count":76,"open_issues_count":3,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-27T01:35:38.700Z","etag":null,"topics":["finite-state-machine","javascript","state","state-machine"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bredele.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-03-18T04:40:53.000Z","updated_at":"2024-05-09T20:57:07.000Z","dependencies_parsed_at":"2022-09-10T19:22:46.193Z","dependency_job_id":null,"html_url":"https://github.com/bredele/mood","commit_stats":null,"previous_names":["bredele/states"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bredele%2Fmood","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bredele%2Fmood/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bredele%2Fmood/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bredele%2Fmood/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bredele","download_url":"https://codeload.github.com/bredele/mood/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650461,"owners_count":21139670,"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":["finite-state-machine","javascript","state","state-machine"],"created_at":"2024-10-31T19:13:01.043Z","updated_at":"2025-04-13T09:32:34.197Z","avatar_url":"https://github.com/bredele.png","language":"JavaScript","funding_links":[],"categories":["Libraries"],"sub_categories":["JavaScript"],"readme":"\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/bredele/mood/blob/master/mood.png\" width=\"200\" height=\"200\" alt=\"mood\"\u003e\n  \u003cbr\u003e\n  \u003ca href=\"https://www.npmjs.org/package/mood\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/mood.svg?style=flat\" alt=\"npm\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://travis-ci.org/bredele/mood\"\u003e\u003cimg src=\"https://travis-ci.org/bredele/mood.svg?branch=master\" alt=\"travis\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://david-dm.org/bredele/mood\"\u003e\u003cimg src=\"https://david-dm.org/bredele/mood/status.svg\" alt=\"dependencies Status\"\u003e\u003c/a\u003e\n  \u003ca href='https://github.com/bredele/contributing-guide/blob/master/guidelines.m'\u003e\u003cimg src=\"https://bredele.github.io/contributing-guide/community-pledge.svg\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\n# Mood\n\nMood is an elegant [state machine](https://en.wikipedia.org/wiki/Finite-state_machine#Concepts_and_terminology) you can use to model large number of problems, among which are UI state management, communication protocol design, language parsing, artificial intelligence and other engineering applications.\n\n  - **Finite state machine**: Use mood to perform predetermined sequence of actions depending on a sequence of events with which they are presented.\n  - **Asynchronous**:  Mood plays well with your favorite libraries and use promises to transition from one state to an other.\n\n\n## Usage\n\n```js\nimport mood from 'mood'\n\n// add transitions from constructor\nconst door = mood('init', {\n  'open' :\n    ['lock', () =\u003e {\n      // do something when the current state is 'open'\n      // and on the 'lock' event\n    },'locked'],\n  'locked': [\n    ['close', 'closed'],\n    ['break', () =\u003e {\n      // do something when the current state is 'locked'\n      // and on the 'break' event\n    }, 'open']\n  ]\n})\n\n// add new transition\n// if transition returns promise, wait for promise to be resolved to trigger state change\ndoor.add('closed', 'knock', function () {\n  return new Promise(resolve =\u003e setTimeout(resolve, 1000))\n}, 'open')\n\n// trigger open-lock transition\ndoor.trigger('lock')\n\n// trigger locked-break transition\ndoor.trigger('break').then(state =\u003e {\n  // do something with new state\n})\n```\n\nCheck out our [API](/test/mood.js) for more information.\n\n## Installation\n\n```shell\nnpm install mood --save\n```\n\n[![NPM](https://nodei.co/npm/mood.png)](https://nodei.co/npm/mood/)\n\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2016 Olivier Wietrich\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbredele%2Fmood","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbredele%2Fmood","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbredele%2Fmood/lists"}