Finity (Deno)

A finite state machine library for Node.js and the browser with a friendly configuration DSL.

Features

See Finity (Node) Features

Example

import Finity from 'https://deno.land/x/finity@1.0.0/mod.ts'
const worker = Finity
    .configure()
    .initialState("ready")
    .on("task_submitted").transitionTo("running")
    .state("running")
    .do((state, context) => processTaskAsync(context.eventPayload))
    .onSuccess().transitionTo("succeeded")
    .onFailure().transitionTo("failed")
    .onTimeout(1000)
    .transitionTo("timed_out")
    .global()
    .onStateEnter(state => console.log(`Entering state '${state}'`))
    .start()

worker.handle("task_submitted", task)

More examples

Usage

See Finity (Node) Usage

TypeScript Support

Finity (Deno) is not written in TypeScript. Finity (Node) includes TypeScript typings which can be used to convert Finity (Deno) to TypeScript (PRs welcome)

License

  • Finity (Deno) is licensed under the MIT license
  • Almost all code is reused from Finity (Node), also under the MIT licnese