Initialises a state machine
const desc = { pants: ['shoes','socks'], socks: ['shoes', 'pants'], shoes: 'shirt', shirt: null}// Defaults to first key, 'pants'let sm = StateMachine.init(descr);// Move to 'shoes' statesm = StateMachine.to(sm, 'shoes');sm.state; // 'shoes'sm.visited; // [ 'pants' ]StateMachineLight.isDdone(sm); // falseStateMachineLight.possible(sm); // [ 'shirt' ] Copy
const desc = { pants: ['shoes','socks'], socks: ['shoes', 'pants'], shoes: 'shirt', shirt: null}// Defaults to first key, 'pants'let sm = StateMachine.init(descr);// Move to 'shoes' statesm = StateMachine.to(sm, 'shoes');sm.state; // 'shoes'sm.visited; // [ 'pants' ]StateMachineLight.isDdone(sm); // falseStateMachineLight.possible(sm); // [ 'shirt' ]
Settings for state machine
Optional
Initial state name
Initialises a state machine