Skip to content

Latest commit

 

History

History
44 lines (31 loc) · 1.36 KB

README.md

File metadata and controls

44 lines (31 loc) · 1.36 KB

Finity (Deno)

A finite state machine library with a friendly configuration DSL.

Features

See Finity (Node) Features

Example

import Finity from 'https://deno.land/x/finity@1.0.3/mod.js'
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