UNPKG

fsmachine

Version:

> A simple and small TypeScript finite state machine

15 lines (14 loc) 707 B
export declare type Callback<TState extends string, TEvent extends string> = (from: TState, event: TEvent, to: TState) => void; export declare type AsyncCallback<TState extends string, TEvent extends string> = (from: TState, event: TEvent, to: TState) => void | Promise<void>; export declare type Options = { name?: string; throw?: boolean; onInvalid?: (from: string, event: string) => void; }; export declare type TransitionMap<TState extends string, TEvent extends string, TCallback = Callback<TState, TEvent>> = Map<TEvent, Map<TState, { to: TState; cb: TCallback; }>>; export declare class InvalidTransition extends Error { constructor(ev: string, from: string); }