{"_id":"fsm-event","_rev":"4632616","name":"fsm-event","description":"Stateful finite state machine wrapper around fsm","dist-tags":{"latest":"2.1.0"},"maintainers":[{"name":"yoshuawuyts","email":"i@yoshuawuyts.com"}],"time":{"modified":"2026-04-10T18:59:30.000Z","created":"2015-05-10T16:30:09.691Z","2.1.0":"2015-09-13T03:02:28.258Z","2.0.0":"2015-06-18T22:20:54.371Z","1.0.3":"2015-05-10T17:26:31.021Z","1.0.2":"2015-05-10T17:01:45.882Z","1.0.1":"2015-05-10T16:53:52.412Z","1.0.0":"2015-05-10T16:30:09.691Z"},"users":{},"repository":{"type":"git","url":"git+https://github.com/yoshuawuyts/fsm-event.git"},"versions":{"2.1.0":{"name":"fsm-event","version":"2.1.0","description":"Stateful finite state machine wrapper around fsm","main":"index.js","scripts":{"test":"standard && NODE_ENV=test node test","test:cov":"standard && NODE_ENV=test istanbul cover test.js"},"repository":{"type":"git","url":"git+https://github.com/yoshuawuyts/fsm-event.git"},"keywords":["state machine","state","simple","unix","minimal","event"],"license":"MIT","dependencies":{"fsm":"^1.0.2"},"devDependencies":{"istanbul":"^0.3.13","standard":"^3.7.3","tape":"^4.0.0"},"files":["LICENSE","index.js","README.md"],"gitHead":"a3ab9e692d39c01c2bdd88d9de9e2a0e07089f85","bugs":{"url":"https://github.com/yoshuawuyts/fsm-event/issues"},"homepage":"https://github.com/yoshuawuyts/fsm-event#readme","_id":"fsm-event@2.1.0","_shasum":"d385716ed38f9c92feab2ba601e2aac6c0ba5a92","_from":".","_npmVersion":"2.14.2","_nodeVersion":"4.0.0","_npmUser":{"name":"yoshuawuyts","email":"i@yoshuawuyts.com"},"dist":{"shasum":"d385716ed38f9c92feab2ba601e2aac6c0ba5a92","size":2932,"noattachment":false,"key":"/fsm-event/-/fsm-event-2.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/fsm-event/download/fsm-event-2.1.0.tgz"},"maintainers":[{"name":"yoshuawuyts","email":"i@yoshuawuyts.com"}],"directories":{},"publish_time":1442113348258,"_hasShrinkwrap":false,"_cnpm_publish_time":1442113348258,"_cnpmcore_publish_time":"2021-12-16T13:38:47.377Z"},"2.0.0":{"name":"fsm-event","version":"2.0.0","description":"Stateful finite state machine wrapper around fsm","main":"index.js","scripts":{"test":"standard && NODE_ENV=test node test","test-cov":"standard && NODE_ENV=test istanbul cover test.js"},"repository":{"type":"git","url":"git+https://github.com/yoshuawuyts/fsm-event.git"},"keywords":["state machine","state","simple","unix","minimal","event"],"license":"MIT","dependencies":{"fsm":"^1.0.2"},"devDependencies":{"istanbul":"^0.3.13","standard":"^3.7.3","tape":"^4.0.0"},"files":["LICENSE","index.js","README.md"],"gitHead":"c932da252d805efdb4f4ecbdf68e215d440817d5","bugs":{"url":"https://github.com/yoshuawuyts/fsm-event/issues"},"homepage":"https://github.com/yoshuawuyts/fsm-event#readme","_id":"fsm-event@2.0.0","_shasum":"0d54d278e735198b4848a7bc5442c7a5f127d1a5","_from":".","_npmVersion":"2.11.0","_nodeVersion":"2.2.1","_npmUser":{"name":"yoshuawuyts","email":"i@yoshuawuyts.com"},"dist":{"shasum":"0d54d278e735198b4848a7bc5442c7a5f127d1a5","size":2898,"noattachment":false,"key":"/fsm-event/-/fsm-event-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/fsm-event/download/fsm-event-2.0.0.tgz"},"maintainers":[{"name":"yoshuawuyts","email":"i@yoshuawuyts.com"}],"directories":{},"publish_time":1434666054371,"_hasShrinkwrap":false,"_cnpm_publish_time":1434666054371,"_cnpmcore_publish_time":"2021-12-16T13:38:47.604Z"},"1.0.3":{"name":"fsm-event","version":"1.0.3","description":"Stateful finite state machine wrapper around fsm","main":"index.js","scripts":{"test":"standard && NODE_ENV=test node test","test-cov":"standard && NODE_ENV=test istanbul cover test.js"},"repository":{"type":"git","url":"git+https://github.com/yoshuawuyts/fsm-event.git"},"keywords":["state machine","state","simple","unix","minimal","event"],"license":"MIT","dependencies":{"fsm":"^1.0.2"},"devDependencies":{"istanbul":"^0.3.13","standard":"^3.7.3","tape":"^4.0.0"},"files":["LICENSE","index.js","README.md"],"gitHead":"60d20b2d4d89775863324657b08e35a25ef5b195","bugs":{"url":"https://github.com/yoshuawuyts/fsm-event/issues"},"homepage":"https://github.com/yoshuawuyts/fsm-event#readme","_id":"fsm-event@1.0.3","_shasum":"200fa6180e4d51c91ad019434fdb0a6542ba0a45","_from":".","_npmVersion":"2.8.3","_nodeVersion":"1.8.1","_npmUser":{"name":"yoshuawuyts","email":"i@yoshuawuyts.com"},"dist":{"shasum":"200fa6180e4d51c91ad019434fdb0a6542ba0a45","size":2816,"noattachment":false,"key":"/fsm-event/-/fsm-event-1.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/fsm-event/download/fsm-event-1.0.3.tgz"},"maintainers":[{"name":"yoshuawuyts","email":"i@yoshuawuyts.com"}],"directories":{},"publish_time":1431278791021,"_hasShrinkwrap":false,"_cnpm_publish_time":1431278791021,"_cnpmcore_publish_time":"2021-12-16T13:38:47.848Z"},"1.0.2":{"name":"fsm-event","version":"1.0.2","description":"Stateful finite state machine wrapper around fsm","main":"index.js","scripts":{"test":"standard && NODE_ENV=test node test","test-cov":"standard && NODE_ENV=test istanbul cover test.js"},"repository":{"type":"git","url":"git+https://github.com/yoshuawuyts/fsm-event.git"},"keywords":["state machine","state","simple","unix","minimal","event"],"license":"MIT","dependencies":{"fsm":"^1.0.2"},"devDependencies":{"istanbul":"^0.3.13","standard":"^3.7.3","tape":"^4.0.0"},"files":["LICENSE","index.js","README.md"],"gitHead":"337afd9f3313ffeed6ef761fc46545257bbbf86d","bugs":{"url":"https://github.com/yoshuawuyts/fsm-event/issues"},"homepage":"https://github.com/yoshuawuyts/fsm-event#readme","_id":"fsm-event@1.0.2","_shasum":"9cf66b230956a8536414beded3680dc03cd43917","_from":".","_npmVersion":"2.8.3","_nodeVersion":"1.8.1","_npmUser":{"name":"yoshuawuyts","email":"i@yoshuawuyts.com"},"dist":{"shasum":"9cf66b230956a8536414beded3680dc03cd43917","size":2805,"noattachment":false,"key":"/fsm-event/-/fsm-event-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/fsm-event/download/fsm-event-1.0.2.tgz"},"maintainers":[{"name":"yoshuawuyts","email":"i@yoshuawuyts.com"}],"directories":{},"publish_time":1431277305882,"_hasShrinkwrap":false,"_cnpm_publish_time":1431277305882,"_cnpmcore_publish_time":"2021-12-16T13:38:48.058Z"},"1.0.1":{"name":"fsm-event","version":"1.0.1","description":"Stateful finite state machine wrapper around fsm","main":"index.js","scripts":{"test":"standard && NODE_ENV=test node test","test-cov":"standard && NODE_ENV=test istanbul cover test.js"},"repository":{"type":"git","url":"git+https://github.com/yoshuawuyts/fsm-event.git"},"keywords":["state machine","state","simple","unix","minimal","event"],"license":"MIT","dependencies":{"fsm":"^1.0.2"},"devDependencies":{"istanbul":"^0.3.13","standard":"^3.7.3","tape":"^4.0.0"},"files":["LICENSE","index.js","README.md"],"gitHead":"aba3c4ee1c36021b356428f472ef60d268e28e0a","bugs":{"url":"https://github.com/yoshuawuyts/fsm-event/issues"},"homepage":"https://github.com/yoshuawuyts/fsm-event#readme","_id":"fsm-event@1.0.1","_shasum":"226b38e5ec5f74fd7cfacda1b9dead9cd3bfabeb","_from":".","_npmVersion":"2.8.3","_nodeVersion":"1.8.1","_npmUser":{"name":"yoshuawuyts","email":"i@yoshuawuyts.com"},"dist":{"shasum":"226b38e5ec5f74fd7cfacda1b9dead9cd3bfabeb","size":2753,"noattachment":false,"key":"/fsm-event/-/fsm-event-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/fsm-event/download/fsm-event-1.0.1.tgz"},"maintainers":[{"name":"yoshuawuyts","email":"i@yoshuawuyts.com"}],"directories":{},"publish_time":1431276832412,"_hasShrinkwrap":false,"_cnpm_publish_time":1431276832412,"_cnpmcore_publish_time":"2021-12-16T13:38:48.311Z"},"1.0.0":{"name":"fsm-event","version":"1.0.0","description":"Stateful finite state machine wrapper around fsm","main":"index.js","scripts":{"test":"standard && NODE_ENV=test node test","test-cov":"standard && NODE_ENV=test istanbul cover test.js"},"repository":{"type":"git","url":"git+https://github.com/yoshuawuyts/fsm-event.git"},"keywords":["state machine","state","simple","unix","minimal","event"],"license":"MIT","dependencies":{"fsm":"^1.0.2"},"devDependencies":{"istanbul":"^0.3.13","standard":"^3.7.3","tape":"^4.0.0"},"files":["LICENSE","index.js","README.md"],"gitHead":"7a0f0d5cd424e92ef8e7a45d6a68b37189928a48","bugs":{"url":"https://github.com/yoshuawuyts/fsm-event/issues"},"homepage":"https://github.com/yoshuawuyts/fsm-event#readme","_id":"fsm-event@1.0.0","_shasum":"0a7c18cd5f57f6ba193a33edcd446e6565b7db2c","_from":".","_npmVersion":"2.8.3","_nodeVersion":"1.8.1","_npmUser":{"name":"yoshuawuyts","email":"i@yoshuawuyts.com"},"dist":{"shasum":"0a7c18cd5f57f6ba193a33edcd446e6565b7db2c","size":2751,"noattachment":false,"key":"/fsm-event/-/fsm-event-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/fsm-event/download/fsm-event-1.0.0.tgz"},"maintainers":[{"name":"yoshuawuyts","email":"i@yoshuawuyts.com"}],"directories":{},"publish_time":1431275409691,"_hasShrinkwrap":false,"_cnpm_publish_time":1431275409691,"_cnpmcore_publish_time":"2021-12-16T13:38:48.597Z"}},"readme":"# fsm-event\n[![NPM version][npm-image]][npm-url]\n[![build status][travis-image]][travis-url]\n[![Test coverage][coveralls-image]][coveralls-url]\n[![Downloads][downloads-image]][downloads-url]\n[![js-standard-style][standard-image]][standard-url]\n\nStateful finite state machine wrapper around\n[`fsm`](https://github.com/dominictarr/fsm). Emits events when transitioning\nstates.\n\n## Installation\n```bash\n$ npm install fsm-event\n```\n\n## Usage\n```js\nconst fsm = require('fsm-event')\n\nconst m = fsm('START', {\n  START: { pause: 'PAUSED' },\n  PAUSED: { resume: 'START' }\n})\n\nm.on('START:leave', cb => console.log('leaving start!'); cb())\nm.on('PAUSED', () => console.log('paused state!'))\n\nm('pause')\n// 'leaving start'\n// 'paused state!'\n```\n\n## API\n### m = fsm([start,] events)\nCreate a state machine. `start` defaults to `START`.\n\n### m.on(event, cb)\nAttach a listener to the state machine. See [events](#Events) for an overview\nof all events.\n\n### m(event)\nTransition states in the state machine. Must be a valid transition defined on\ninitalization. Will throw if an invalid transition is triggered. Alias:\n`m.emit(event)`.\n\n## Events\nEach state transition triggers 3 events. __important:__ When listening to\n`:enter` or `:leave` events, the callback must be called so that the state\nmachine can proceed to the next state.\n```txt\nerror           incorrect transition\n<state>         when new state is entered\n<state>:enter   when transitioning into state\n<state>:leave   when transitioning away from state\ndone            when state transition finished\n```\n\n## Why?\nMost state machines have overly complicated interfaces for managing state. The\nfsm state machine is simple but doesn't manage state for you, so I wrote a\nwrapper around it that manages state in an event-driven way. The initial use\ncase was to manage complex, stateful UI elements but it can be used anywhere.\n\n## See Also\n- [fsm](https://github.com/dominictarr/fsm)\n- [javascript-state-machine](https://github.com/jakesgordon/javascript-state-machine)\n- [statement](https://github.com/timoxley/statement)\n- [stream-fsm](https://www.npmjs.com/package/stream-fsm)\n\n## License\n[MIT](https://tldrlegal.com/license/mit-license)\n\n[npm-image]: https://img.shields.io/npm/v/fsm-event.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/fsm-event\n[travis-image]: https://img.shields.io/travis/yoshuawuyts/fsm-event/master.svg?style=flat-square\n[travis-url]: https://travis-ci.org/yoshuawuyts/fsm-event\n[coveralls-image]: https://img.shields.io/coveralls/yoshuawuyts/fsm-event.svg?style=flat-square\n[coveralls-url]: https://coveralls.io/r/yoshuawuyts/fsm-event?branch=master\n[downloads-image]: http://img.shields.io/npm/dm/fsm-event.svg?style=flat-square\n[downloads-url]: https://npmjs.org/package/fsm-event\n[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square\n[standard-url]: https://github.com/feross/standard\n","_attachments":{},"homepage":"https://github.com/yoshuawuyts/fsm-event#readme","bugs":{"url":"https://github.com/yoshuawuyts/fsm-event/issues"},"license":"MIT"}