UNPKG

statewave

Version:
20 lines (17 loc) 504 B
import { Transition, Immediate, State } from "."; // export type StateArgs<E, S> = ; export function state<S, E>( ...args: (Transition<S, E> | Immediate<S> | undefined)[] ): State<S, E> { const transitions = args.filter((arg) => arg && "__transition" in arg() ? true : false ) as Transition<S, E>[]; const immediates = args.filter((arg) => arg && "__immediate" in arg() ? true : false ) as Immediate<S>[]; return () => ({ __state: true, transitions, immediates, }); }