Metakit / @doeixd/metakit/machine
each
function · packages/metakit/src/machineEach.ts:431
function each<
Outer,
Child,
K extends keyof Child & string,
Transitions extends Readonly<Record<string, unknown>>,
>(
list: Path.Path<Outer, ReadonlyArray<Child>>,
select: Path.Selector<NoInfer<Child>, K>,
child: Machine<Child, Transitions>,
): EachLifted<Outer, K, Child[K], Transitions>Lift every transition of a child machine over a keyed list list: with
each => each.sku, each transition's input gains { sku: Child['sku'] },
targeting the element(s) whose sku field equals that input value by
Eq.is, and keeping every check of the child's input. Refuses at
definition time if the selector returns anything but one field of the
element, if a child transition's input is not a plain Schema.Struct, or
if a child transition has ensures: a postcondition is not lifted over the
element yet, and is not dropped.