Metakit / @doeixd/metakit/machine

make

function · packages/metakit/src/machine.ts:104

function make<
  S extends Schema.Top,
  Given extends Readonly<Record<string, AnyTransition<S['Type']>>>,
>(config: {
  readonly state: S
  readonly start?: S['Type']
  readonly transitions: Given
}): Machine<S['Type'], Arms<Given>>

Construct a declarative state machine from a Schema and a map of Transitions. Its transitions are arms: copies named by their keys, so one transition given under two keys gives two arms. An optional start is one state, checked against state here (a rejected one throws, naming the failing field); readers that need somewhere to begin use it.