whenIsBoolTruthy
Callback executed only for EitherBoolTruthy 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>, EitherBoolTruthy>>) => GenericOutput
): GenericOutput | Exclude<ToEither<GenericInput>, EitherBoolTruthy>;Curried signature
typescript
function whenIsBoolTruthy<
const GenericInput extends unknown,
const GenericOutput extends AnyValue | EscapeVoid
>(
theFunction: (value: Unwrap<Extract<ToEither<GenericInput>, EitherBoolTruthy>>) => GenericOutput
): (input: GenericInput) => GenericOutput | Exclude<ToEither<GenericInput>, EitherBoolTruthy>;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 (EitherBoolFalsy).
See also
whenIsBoolFalsy.bool– To generate the truthy/falsy source.
