State machines are awesome but can be pretty daunting as a system grows. Keeping states, transitions, & events straight can be tricky. StateJacket simplifies things by isolating the management of states & transitions. Events are left out, making it much easier to reason about what states exist and how they transition to other states.
The examples below are somewhat contrived, but should clearly illustrate the usage.
$ npm install state-jacket
var StateJacket = require'state-jacket';var states = ;statesadd'open' 'closed' 'error';statesadd'closed' 'open' 'error';statesadd'error';stateslock;statestransitioners; // => ['open', 'closed']statesterminators; // => ['error']statescanTransition'open' 'closed'; // => truestatescanTransition'closed' 'open'; // => truestatescanTransition'error' 'open'; // => falsestatescanTransition'error' 'closed'; // => false