whenIsBoolTruthy
Callback executed only for BoolTruthy values. Otherwise, the initial value is returned.
Interactive example
Syntax
Classic signature
typescript
function whenIsBoolTruthy<
const GenericInput extends unknown,
const GenericOutput extends AnyValue | EscapeVoid
>(
input: GenericInput,
theFunction: (value: Unwrap<Extract<ToEither<GenericInput>, BoolTruthy>>) => GenericOutput
): GenericOutput | Exclude<ToEither<GenericInput>, BoolTruthy>;Curried signature
typescript
function whenIsBoolTruthy<
const GenericInput extends unknown,
const GenericOutput extends AnyValue | EscapeVoid
>(
theFunction: (value: Unwrap<Extract<ToEither<GenericInput>, BoolTruthy>>) => GenericOutput
): (input: GenericInput) => GenericOutput | Exclude<ToEither<GenericInput>, BoolTruthy>;Parameters
theFunction: Function executed only when the value is truthy.input: Value orEitherto process (optional in the curried version).
Return value
The result of theFunction for truthy values, otherwise the original value (BoolFalsy).
See also
whenIsBoolFalsy.bool– To generate the truthy/falsy source.
