simple-machine

0.2.0 • Public • Published
  .~~~~~~~~~~~~~~~.
 /  VERSION 0.1.0  \
.===================.
|                   |
|   .-----------.   |
|   |.,.,.,.,.,.|   |
|   |,.,.,.,.,.,|   |
|   |.,.,.,.,.,.|   |
|   |,.,.,.,.,.,|   |
|   '-----------'   |
|                 O |
|===================|
| ~~~~~~~~~~~~~~~~~ |
|  simple  machine  |
| ~~~~~~~~~~~~~~~~~ |
'==================='

How many lines of code you need for a finite state machine? 16... 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.

Readme

Keywords

none

Package Sidebar

Install

npm i simple-machine

Weekly Downloads

2

Version

0.2.0

License

none

Last publish

Collaborators

  • gsamokovarov