Install the package via NPM:
npm install state-machine
State Machine can be used directly in the browser, in a Browserify, Node or ES5 project.
For direct browser use, copy the minified file from dist/
and load via a script tag:
<script src="dist/state-machine.min.js"></script>
Then instantiate the State Machine elsewhere:
<script>
var fsm = new StateMachine(options);
</script>
For Node or Browserify, require and instantiate depending on your requirements:
// state machine
var StateMachine = require('state-machine').StateMachine;
var fsm = new StateMachine(options);
// helper
var StateHelper = require('state-machine').StateHelper;
StateHelper.object(fsm);
For an ES6 project, import and instantiate depending on your requirements:
// default import
import StateMachine from 'state-machine';
// named imports
import { StateMachine, StateHelper } from 'state-machine';
// state machine
const fsm = new StateMachine(options);
// helper
StateHelper.object(fsm);