1.2.0 • Published 9 years ago
min-state v1.2.0
min-state
Simple finite state machine library for javascript
Installation
npm i min-stateApi
Constructor
var state = new State({
start: 'idle', // default state name
end: 'ended' // if set, can never be set again
})method
state.is(stateName)return true if current state name is valstate.set(stateName)set state current statestate.get()get state current statestate.setEvent(stateName, from, to)set event which can only transition from stateA to stateBstate.setEvents({stateName: {from: stateA, to: stateB}})multiply set event
use '*' for from which can transition from any state
events
enter, stateexit, statestatechange, {from: stateA, to: stateB}invalid, eventName
example
check example.js for example