bool
Converts any value into a boolean monad (EitherBoolTruthy or EitherBoolFalsy). Handy to keep track of the test while benefiting from the whenIsBoolTruthy/whenIsBoolFalsy helpers.
Interactive example
Syntax
typescript
function bool<
const GenericInput extends unknown = undefined
>(
input: GenericInput
): GenericInput extends BoolFalsyValue
? EitherBoolFalsy<GenericInput>
: EitherBoolTruthy<GenericInput> | EitherBoolFalsy<BoolFalsyValue>;Parameters
input: Value to interpret. Standard falsy values ("",0,false,null,undefined) produce aLeft.
Return value
An Either: Right<"bool"> when the value is truthy, Left<"bool"> otherwise. Typing preserves the original value.
See also
boolTruthy&boolFalsy.whenIsBoolTruthy– To act only on truthy values.
