🤖 Robot

Fast 1kB functional library for creating Finite State Machines

Robot exports a variety of functions that compose to build state machines. Many of the functions, such as state and transition are variadic, meaning they can take any number of arguments and the order doesn't matter (much). This is a common pattern you'll notice in usage; the result is easier composition.

# Main exports

Table of Contents

# Debugging

Robot does not verify the correct of the state machines you create by default. This is for bundle size purposes; in production you wouldn't want your machines to throw, and this code takes up valuable space.

Instead debugging messages are provided by the debug module, robot3/debug. Simply import the module anywhere before you call createMachine.

A common pattern is to have a dev.js that imports the debug module and your main. This way the dev.js is not included in your production build.

dev.js

import 'robot3/debug';
import './main.js';

Or if you're using web modules then include a script tag before your main:

<script type="module" src="https://unpkg.com/robot3/debug"></script>
<script type="module" src="./main.js"></script>