simple-fsm

Create simple finite state machines

npm install simple-fsm
6 downloads in the last week
12 downloads in the last month

Build Status endorse

simple-fsm

Create simple finite state machines

Nodejs

Installation

$ npm install simple-fsm --save

Usage

var fsm = require('simple-fsm');
var machine = fsm.create({
    OFF:{ toggle: function(){ this.ON(); } },
    ON:{ toggle: function(){ this.OFF(); } }
}).OFF(); // set the initial state to OFF

Browser

Installation (bower)

$ bower install simple-fsm --save

Usage

<script src="bower_components/simple-fsm/src/simple-fsm.js"></script>
<script>
    var machine = fsm.create({
        OFF:{ toggle: function(){ this.ON(); } },
        ON:{ toggle: function(){ this.OFF(); } }
    }).OFF(); // set the initial state to OFF
</script>
npm loves you