{"id":24107719,"url":"https://github.com/barteh/machinize","last_synced_at":"2025-10-18T01:29:48.788Z","repository":{"id":51079785,"uuid":"140457360","full_name":"barteh/machinize","owner":"barteh","description":"a javascript library implements finite-state machine for application developement purpose","archived":false,"fork":false,"pushed_at":"2023-01-03T15:16:16.000Z","size":355,"stargazers_count":10,"open_issues_count":9,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-19T03:10:54.676Z","etag":null,"topics":["barteh","bornamehrfann","finite-state-machine","fsm","javascript","library","machinize","rafat"],"latest_commit_sha":null,"homepage":null,"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/barteh.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":"2018-07-10T16:06:04.000Z","updated_at":"2022-12-12T16:56:03.000Z","dependencies_parsed_at":"2023-02-01T07:01:08.564Z","dependency_job_id":null,"html_url":"https://github.com/barteh/machinize","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barteh%2Fmachinize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barteh%2Fmachinize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barteh%2Fmachinize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barteh%2Fmachinize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/barteh","download_url":"https://codeload.github.com/barteh/machinize/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253796524,"owners_count":21965734,"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":["barteh","bornamehrfann","finite-state-machine","fsm","javascript","library","machinize","rafat"],"created_at":"2025-01-10T22:52:47.384Z","updated_at":"2025-10-18T01:29:48.713Z","avatar_url":"https://github.com/barteh.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n[![Build Status](https://travis-ci.org/barteh/machinize.svg?branch=master)](https://travis-ci.org/barteh/machinize) \u003c!--[![Coverage Status](https://coveralls.io/repos/github/barteh/machinize/badge.svg?branch=master)](https://coveralls.io/github/barteh/machinize?branch=master) --\u003e\n\n# Machinize\n## a javascript library implements finite-state machine for application developement purpose\n\n\n## main features\n\n- change objects to machine automaticly.\n- define machine behavior once and create many instances.\n- automatic transitions with defined condition.\n- supports parametric observable (source state, destinition state or both) observable state changes based on rxjs.\n- supports blockable hooks contain(befor, after Enter and exit) from or to  states.\n- data included access via `this` .\n- define  auto transition by a condition.\n- imutable state.\n- actions that acces to `this` so data and parameters.\n- supports computed data .\n- many usefull features will be document soon\n\n\n\n![](https://upload.wikimedia.org/wikipedia/commons/thumb/c/cf/Finite_state_machine_example_with_comments.svg/420px-Finite_state_machine_example_with_comments.svg.png)\n\n\n\n---\n### install\n```\nnpm i @barteh/machinize\n```\n---\n### usage\n```js\nimport Machinize from \"@barteh/machinize\"\nconst machine = Machinize.init({\n    name: \"myMachine\",\n    data: {\n        light: 55 // of 100\n    },\n\n    states: {\n        \"off\": {\n            description: \"light is off\"\n\n        },\n        \"on\": {\n            description: \"light is on\",\n            onEnter() { // auto off after 2s\n                \n                // setTimeout(() =\u003e {\n                //     if (this.light \u003c 60) \n                //         this.switchoff();\n                // }, 1000);\n            }\n        }\n      \n    },\n    transitions: {\n        \"switchon\": {\n            from: \"off\",\n            to: \"on\"\n        },\n        \"switchoff\": {\n            from: \"on\",\n            to: \"off\",\n            entryCondition(){\n                return this.light\u003c55;\n            }\n        }\n\n    },\n    actions: {\n        do_on() {\n            this.switchon();\n        }\n    }\n\n});\n\nconst machinInstance = machine.createInstance({light: 31});\n\nmachinInstance\n    .$observable()\n    .subscribe(a =\u003e {\n        console.log( a.message)\n    })\n\nmachinInstance.do_on(); // light is on\n\nsetTimeout(() =\u003e {\n    machinInstance.light=44; //light is off\n}, 2000);\n\n```\n\n\n---\n### test\n```\nnpm run test\n``` \n---\n### build\n\n```\nnpm run build\n```\n\n\n\nLicense: MIT\n2017\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbarteh%2Fmachinize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbarteh%2Fmachinize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbarteh%2Fmachinize/lists"}