{"id":18658374,"url":"https://github.com/shime/micro-machine","last_synced_at":"2025-09-06T14:46:31.590Z","repository":{"id":12929067,"uuid":"15606748","full_name":"shime/micro-machine","owner":"shime","description":"Minimal state machine.","archived":false,"fork":false,"pushed_at":"2014-09-22T10:18:52.000Z","size":308,"stargazers_count":9,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-14T07:52:31.592Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shime.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-01-03T10:10:42.000Z","updated_at":"2024-04-08T18:13:52.000Z","dependencies_parsed_at":"2022-07-09T23:46:19.444Z","dependency_job_id":null,"html_url":"https://github.com/shime/micro-machine","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shime%2Fmicro-machine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shime%2Fmicro-machine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shime%2Fmicro-machine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shime%2Fmicro-machine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shime","download_url":"https://codeload.github.com/shime/micro-machine/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223477223,"owners_count":17151603,"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-11-07T07:32:41.049Z","updated_at":"2024-11-07T07:32:41.863Z","avatar_url":"https://github.com/shime.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Micro Machine\n\n[![Build Status](https://travis-ci.org/shime/micro-machine.svg?branch=master)](https://travis-ci.org/shime/micro-machine)\n\nMinimal state machine implementation.\n\nHeavily inspired by [soveran/micromachine](https://github.com/soveran/micromachine).\n\n### Installation\n\n```shell\nnpm install micro-machine\n```\n\n### Usage\n\n```javascript\nvar Machine = require('micro-machine')\n  , machine = new Machine('pending')\n\nmachine.transitionsFor.confirm = { pending: 'confirmed' }\nmachine.transitionsFor.reset = { confirmed: 'pending' }\n\nmachine.trigger('confirm')\nconsole.log(machine.state) // 'confirmed'\nmachine.trigger('reset')\nconsole.log(machine.state) // 'pending'\n```\n\n### Callbacks\n\nYou can also define callbacks that will be invoked after the specified transition.\n\n```javascript\nvar Machine = require('micro-machine')\n  , machine = new Machine('pending')\n  \nmachine.transitionsFor.confirm = { pending: 'confirmed' }\nmachine.transitionsFor.reset = { confirmed: 'pending' }\n\nvar state\n\n/* Use 'any' to define callback for any transition. */\nmachine.on('any',  function(machine){\n  state = machine.state\n})\n\nmachine.on('reset', function() { console.log('resetting...') })\n\nmachine.trigger('confirm')\nconsole.log(state)  // 'confirmed'\n\nmachine.trigger('reset') // 'resetting...'\n```\n\n### Development\n\nRun tests with\n\n    npm test\n\nor build it with\n\n    npm run build\n\n### Unlicense\n\nThis repository and its contents belong to the public domain.\n\nIt has been released under the [UNLICENSE](https://github.com/shime/micro-machine/blob/master/UNLICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshime%2Fmicro-machine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshime%2Fmicro-machine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshime%2Fmicro-machine/lists"}