it-fsm/README.md

1.1 KiB

IT FSM

ci Coverage Status

Simple full-featured finite state machine for your project

Why it-fsm?

  • 🚯 333 LOC - 0 dependencies
  • 🍒 Sophisticated object-oriented design

Getting started

import { StateMachineBuilder } from "it-fsm";

const [locked, unlocked] = ['locked', 'unlocked'] as const;

const sm = new StateMachineBuilder()
  .withStates([locked, unlocked])
  .withTransitions([
    [locked, { coin: unlocked }],
    [unlocked, { push: locked }],
  ])
  .build(locked);

or with deno

import { StateMachineBuilder } from "https://raw.githubusercontent.com/icetemple/it-fsm/master/fsm.ts";

// ...

You can find the full example in the examples folder.

Install

If you want to use it in Node.js or the browser, you may need to install it as follows

npm install --save it-fsm