@cicerchie/fsm

A fast and carefree Typescript state machine.

Usage no npm install needed!

<script type="module">
  import cicerchieFsm from 'https://cdn.skypack.dev/@cicerchie/fsm';
</script>

README

Cicerchie FSM

A fast and carefree Typescript state machine.

Lastest release License Github repo dependents Github pkg dependents Github open issues Github status Bundlephobia MinZip Bundlephobia dependency count Snyk Npm version Npm DT Npm dependents Npm types David DM dep David DM dev-dep David DM peer-dep


WARNING!

These components are still "experimental" (v0.x.x).
Some of them are not tested as rigourously as it should be and none of them have been through code review.
Use them at your own risk and check that them do what you want them to do.


Installation

npm install -D @cicerchie/fsm

Usage

You can see how it's used in @cicerchie/svelte-swr project.

Changelog

Is automagically updated with each release and you can read it here.

Features

  • Finite states (non-nested)
  • Initial state
  • Transitions (object)
  • Transitions (string target)
  • Delayed transitions
  • Context
  • Entry actions
  • Exit actions
  • Transition actions
  • Transition guards
  • Parameterized actions
  • Async actions with onDone/onError
  • Typescript ready (still incomplete and so many any!)

TODO

  • Docs (HELP!)
  • Tests (HELP!)
  • Demo site (using routes dir: it's a SvelteKit app!)

Motivation

This project was born after looking for a good typed library for massive use in low-end devices.

Neither Robot (it is not written in Typescript) nor XState (too big) nor its "mini version" @xstate/fsm (lacking essential features) did satisfy us.

By chance we found the great article by @dimfeld that lit the way: what a golden boy!