1.2.0 • Published 8 years ago

min-state v1.2.0

Weekly downloads
-
License
ISC
Repository
-
Last release
8 years ago

min-state

NPM version Downloads Dependency Status

Simple finite state machine library for javascript

Installation

npm i min-state

Api

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 val
  • state.set(stateName) set state current state
  • state.get() get state current state
  • state.setEvent(stateName, from, to) set event which can only transition from stateA to stateB
  • state.setEvents({stateName: {from: stateA, to: stateB}}) multiply set event

use '*' for from which can transition from any state

events

  • enter, state
  • exit, state
  • statechange, {from: stateA, to: stateB}
  • invalid, eventName

example

check example.js for example

License

License

1.2.0

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago