it-fsm/README.md

38 lines
518 B
Markdown
Raw Normal View History

2019-10-11 10:54:07 +03:00
# IT FSM
Simple finite state machine
2019-10-17 13:54:15 +03:00
2019-10-19 20:27:06 +03:00
[![Build Status](https://travis-ci.com/icetemple/npm-it-fsm.svg?branch=master)](https://travis-ci.com/icetemple/npm-it-fsm)
2019-10-17 13:54:15 +03:00
### Installation
`npm install --save it-fsm`
### Usage
```javascript
import { StateMachine } from 'it-fsm';
const fsm = new StateMachine('TODO', {
TODO: {
complete: 'COMPLETE'
}
})
if (fsm.can('complete')) {
fsm.complete().then(() => {
})
}
// or
if (fsm.canToState('COMPLETE')) {
fsm.complete().then(() => {
});
}
```