statewave
Version:
Another Finite State Machine
26 lines (23 loc) • 719 B
text/typescript
import { MachineConfig, MachineState } from ".";
import { deepFreeze } from "./utils";
/**
* Returns a machine schema to be interpreted.
*
* @remarks
* This function create the machine schema for interpreting.
*
* @param states - 1 or more MachineState configurations
* @param options - Optional detail for controlling machine behavior
* @returns Returns a Machine schema definition to be interpreted
*
* @beta
*/
export function machine<S extends string | number | symbol, E>(
states: Array<MachineState<S, E>> | MachineState<S, E>,
options?: MachineConfig<S>
): {
states: Array<MachineState<S, E>> | MachineState<S, E>;
options?: MachineConfig<S>;
} {
return deepFreeze({ states, options });
}