Micro Machine
Minimal state machine implementation.
Heavily inspired by soveran/micromachine.
Installation
npm install micro-machine
Usage
var Machine = machine = 'pending' machinetransitionsForconfirm = pending: 'confirmed' machinetransitionsForreset = confirmed: 'pending' machineconsole // 'confirmed'machineconsole // 'pending'
Callbacks
You can also define callbacks that will be invoked after the specified transition.
var Machine = machine = 'pending' machinetransitionsForconfirm = pending: 'confirmed' machinetransitionsForreset = confirmed: 'pending' var state /* Use 'any' to define callback for any transition. */machine machine machineconsole // 'confirmed' machine // 'resetting...'
Development
Run tests with
npm test
or build it with
npm run build
Unlicense
This repository and its contents belong to the public domain.
It has been released under the UNLICENSE.