{"name":"fsm-base","author":{"name":"Lloyd Brookes","email":"75pound@gmail.com"},"version":"0.9.0","description":"Finite state machine base class","repository":{"type":"git","url":"git+https://github.com/75lb/fsm-base.git"},"license":"MIT","type":"module","exports":{"import":"./index.js","require":"./dist/index.cjs"},"keywords":["finite","state","machine","base","class","isomorphic","load-anywhere"],"engines":{"node":">=12.17"},"scripts":{"test":"npm run dist && npm run test:ci","test:ci":"test-runner test.js","docs":"jsdoc2md index.js > docs/api.md","dist":"rollup -c"},"devDependencies":{"@rollup/plugin-node-resolve":"^15.2.3","jsdoc-to-markdown":"^8.0.1","rollup":"^4.18.0","test-runner":"^0.10.1"},"dependencies":{"array-back":"^6.2.2"},"standard":{"ignore":["dist"]},"_id":"fsm-base@0.9.0","gitHead":"11fac9ba803f817855b0ace27082da9aecca774d","bugs":{"url":"https://github.com/75lb/fsm-base/issues"},"homepage":"https://github.com/75lb/fsm-base#readme","_nodeVersion":"22.4.0","_npmVersion":"10.8.1","dist":{"integrity":"sha512-ahGioVoAl07F6HHgQYrYeisB96ESJoZDQomz7fLUci1/pNmrdV1aWTJ2qLkqQNTRt9pqs+maAy+T26WkRdvB8g==","shasum":"ce5981e782e2d466f7a6a7372142b29d0cc0fd54","tarball":"http://registry-npm.ywwl.com/fsm-base/download/fsm-base-0.9.0.tgz","fileCount":6,"unpackedSize":15607,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHMsGzCa5jkmzy8Ja1G+Mjj5kmfEckkiKJXpB9Oody5mAiBvBcP6R+3vdc+SZV05vitVcBNHBs/xv0/M5dZWfUvXiA=="}],"size":3586,"noattachment":false,"key":"/fsm-base/-/fsm-base-0.9.0.tgz"},"_npmUser":{"name":"75lb","email":"75pound@gmail.com"},"directories":{},"maintainers":[{"name":"75lb","email":"75pound@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/fsm-base_0.9.0_1720272782292_0.44445201904610254"},"_hasShrinkwrap":false,"readme":"[![view on npm](https://badgen.net/npm/v/fsm-base)](https://www.npmjs.org/package/fsm-base)\n[![npm module downloads](https://badgen.net/npm/dt/fsm-base)](https://www.npmjs.org/package/fsm-base)\n[![Gihub repo dependents](https://badgen.net/github/dependents-repo/75lb/fsm-base)](https://github.com/75lb/fsm-base/network/dependents?dependent_type=REPOSITORY)\n[![Gihub package dependents](https://badgen.net/github/dependents-pkg/75lb/fsm-base)](https://github.com/75lb/fsm-base/network/dependents?dependent_type=PACKAGE)\n[![Node.js CI](https://github.com/75lb/fsm-base/actions/workflows/node.js.yml/badge.svg)](https://github.com/75lb/fsm-base/actions/workflows/node.js.yml)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](https://github.com/feross/standard)\n\n# fsm-base\n\nFinite state machine.\n\nEither mix it into an existing object:\n\n```js\nimport StateMachine from 'fsm-base'\n\nconst device = {}\nStateMachine.mixInto(device)\n\ndevice._initStateMachine('offline', [\n  { from: 'offline', to: 'connecting' },\n  { from: 'connecting', to: 'online' },\n  { from: ['connecting', 'online'], to: 'offline' }\n])\n\ndevice.onStateChange = function (state, prevState) {\n  console.log(state, prevState)\n}\n\ndevice.state = 'connecting'\ndevice.state = 'connecting' // should not trigger events again\ndevice.state = 'online'\ndevice.state = 'offline' // valid state move\n```\n\n..or define a class which extends it:\n\n```js\nclass Device extends StateMachine {}\n\nconst device = new Device()\ndevice._initStateMachine('offline', [\n  { from: 'offline', to: 'connecting' },\n  { from: 'connecting', to: 'online' },\n  { from: ['connecting', 'online'], to: 'offline' }\n])\n\ndevice.onStateChange = function (state, prevState) {\n  console.log(state, prevState)\n}\n\ndevice.state = 'connecting'\n// etc\n```\n\n..or mix it into an existing class that does not `extend` fsm-base.\n\n```js\nclass Device {}\nStateMachine.mixInto(Device)\n\nconst device = new Device()\ndevice._initStateMachine('offline', [\n  { from: 'offline', to: 'connecting' },\n  { from: 'connecting', to: 'online' },\n  { from: ['connecting', 'online'], to: 'offline' }\n])\n\ndevice.onStateChange = function (state, prevState) {\n  console.log(state, prevState)\n}\n\ndevice.state = 'connecting'\n//etc\n```\n\nSee the [API Documentation](https://github.com/75lb/fsm-base/tree/master/docs/api.md) for more information.\n\n* * *\n\n&copy; 2015-24 Lloyd Brookes \\<75pound@gmail.com\\>. Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).\n","publish_time":1720272782438,"_cnpm_publish_time":1720272782438,"dist-tags":{"latest":"0.9.0"}}