Metakit / @doeixd/metakit/fn
ifElse
function · packages/metakit/src/fnCombinators.ts:222
function ifElse<
PC extends ParamSchemas,
RC extends boolean | null,
PT extends ParamSchemas,
PF extends ParamSchemas,
RT,
RF,
>(
cond: Fn<PC, RC>,
onTrue: Fn<PT, RT>,
onFalse: Fn<PF, RF>,
): Fn<PC & PT & PF, RT | RF | (null extends RC ? null : never)>Conditional branching combinator: evaluates onTrue when cond is true,
onFalse when cond is false, and null when cond is null.
Each branch's preconditions and obligations are guarded by the exact branch
path condition (cond === true / cond === false), so cond === null
discharges neither branch's contracts.