Simple state machine for Node and the Browser.
CoffeeScript JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
src
test
.gitignore
Gruntfile.coffee
LICENSE
README.markdown
index.js
package.json
simple-machine.min.js

README.markdown

  .~~~~~~~~~~~~~~~.
 /  VERSION 0.2.0  \
.===================.
|                   |
|   .-----------.   |
|   |.,.,.,.,.,.|   |
|   |,.,.,.,.,.,|   |
|   |.,.,.,.,.,.|   |
|   |,.,.,.,.,.,|   |
|   '-----------'   |
|                 O |
|===================|
| ~~~~~~~~~~~~~~~~~ |
|  simple  machine  |
| ~~~~~~~~~~~~~~~~~ |
'==================='

How many lines of code you need for a finite state machine? 15... of CoffeeScript that is.

Simple Machine?

A minimal finite state machine implementation for the Node and the Browser. There is no DSLs and no bloat. Just define and trigger states.

Installation

If you are running on Node, use NPM:

npm install simple-machine

If you are running on the Browser, use this this link.

Usage

machine = new SimpleMachine 'S',
  A: {S: 'A', B: 'A', C: 'A'}
  B: {S: 'B', C: 'B', A: 'B'}
  C: {S: 'C', A: 'C', B: 'C'}
,
  A: -> console.log 'A'
  B: -> console.log 'B'
  C: -> console.log 'C'

machine.trigger 'A'
machine.trigger 'B'
machine.trigger 'C'

License

Simple machine is licensed under MIT.