https://github.com/cicerchie/fsm
Fast and carefree Typescript state machine.
https://github.com/cicerchie/fsm
state-machine state-machines typescript typescript-library
Last synced: 4 months ago
JSON representation
Fast and carefree Typescript state machine.
- Host: GitHub
- URL: https://github.com/cicerchie/fsm
- Owner: cicerchie
- License: mit
- Created: 2021-08-19T17:57:57.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2021-08-22T13:22:17.000Z (about 4 years ago)
- Last Synced: 2025-03-13T15:15:44.949Z (7 months ago)
- Topics: state-machine, state-machines, typescript, typescript-library
- Language: TypeScript
- Homepage:
- Size: 81.1 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Cicerchie FSM
A fast and **carefree** Typescript state machine.















---
### 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](https://github.com/cicerchie/svelte-swr) project.
## Changelog
Is automagically updated with each release and [you can read it here](https://github.com/cicerchie/fsm/blob/master/CHANGELOG.md).
## Features
- [x] Finite states (non-nested)
- [x] Initial state
- [x] Transitions (object)
- [x] Transitions (string target)
- [x] Delayed transitions
- [x] Context
- [x] Entry actions
- [x] Exit actions
- [x] Transition actions
- [x] Transition guards
- [x] Parameterized actions
- [x] 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](https://github.com/matthewp/robot) (it is not written in Typescript) nor [XState](https://github.com/statelyai/xstate) (too big) nor its "mini version" [@xstate/fsm](https://xstate.js.org/docs/packages/xstate-fsm/) (lacking essential features) did satisfy us.
By chance we found [the great article](https://imfeld.dev/writing/simple_state_machines) by [@dimfeld](https://github.com/dimfeld) that lit the way: what a golden boy!