Coder Social home page Coder Social logo

pleshevskiy / it-fsm Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 0.0 723 KB

Simple full-featured finite state machine for your project. Mirror of https://git.pleshevski.ru/pleshevskiy/it-fsm

License: GNU General Public License v3.0

TypeScript 92.17% Makefile 4.58% Nix 3.25%
finite-state-machine fsm typescript finite state machine ood oop

it-fsm's Introduction

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);

You can find more examples here

Installation

Deno

if you use the Deno, just add the following to your import_map.json

{
  "imports": {
    "it-fsm": "https://git.pleshevski.ru/pleshevskiy/it-fsm/raw/tag/v2.0.3/fsm.ts"
  }
}

Node.js

If you use the Node.js or in a browser as ES module, you may need to install it as follows, and additionally you can add import maps for client side.

npm install --save it-fsm

License

GNU General Public License v3.0 or later

See COPYING to see the full text.

it-fsm's People

Contributors

dependabot[bot] avatar pleshevskiy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

it-fsm's Issues

Use Map instead Object

Object can have only string keys and it's problem. Currently we have crutch with number key. We test key by regex and parse it.

With Map object we may store any object as a key!

Get action by state

Imagine FSM for task statuses. We want to handle state action if status change. We shouldn't copy-paste if-else condition to run state action. The FSM should give us a method to get action by state.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.