async-fsm.js
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

async-fsm.js

Commitizen friendly

a finite state machine implementation

Quick Start

npm i async-fsm.js

Test

npm run test

Features

  • asynchronous onEnter, onLeave hooks
  • asynchronous check if operation is available
  • available operations
  • comprehensive error checking

Example

const { Fsm } = require('async-fsm.js')
const fsm = new Fsm()
  .addState(new State("started")
    .routes({
      finish: "ended",
    })
  )
  .addState("ended");

const fsmInstance = fsm.createInstance("started").bundle({ foo: "abc" });
await fsmInstance.perform('finish');
expect(fsmInstance.state.name).toBe('ended');

please check test for more examples.

Readme

Keywords

none

Package Sidebar

Install

npm i async-fsm.js

Weekly Downloads

2

Version

3.0.0

License

MIT

Unpacked Size

299 kB

Total Files

32

Last publish

Collaborators

  • xiechao06