Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kwangure/hine-archive
A state machine library
https://github.com/kwangure/hine-archive
finite-state-machine fsm state state-machine
Last synced: about 2 months ago
JSON representation
A state machine library
- Host: GitHub
- URL: https://github.com/kwangure/hine-archive
- Owner: kwangure
- Created: 2023-02-26T13:19:13.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-22T07:05:43.000Z (9 months ago)
- Last Synced: 2024-10-15T19:27:26.699Z (3 months ago)
- Topics: finite-state-machine, fsm, state, state-machine
- Language: JavaScript
- Homepage: https://hine.dev
- Size: 3.54 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
A JavaScript state machine library.
### Install
```bash
npm install hine
```### Getting started
```javascript
import { atomic, compound } from 'hine';// Compound states have `children`
const toggle = compound({
// The first state (in this case 'inactive') is the default initial state
children: {
// Atomic states do not have `children`. They're leaves in the tree.
inactive: atomic({
on: {
// `goto` will change the current state after a 'toggle' event
toggle: { goto: 'active' },
},
}),
active: atomic({
on: {
toggle: { goto: 'inactive' },
},
}),
},
});toggle.resolve();
toggle.matches('inactive'); // true
toggle.dispatch('toggle');
toggle.matches('active'); // true
```