Skip to content

whenIsBoolFalsy

Applies a callback only when the boolean value is falsy.

Interactive example

Syntax

Classic signature

typescript
function whenIsBoolFalsy<
  const GenericInput extends unknown,
  const GenericOutput extends AnyValue | EscapeVoid
>(
  input: GenericInput,
  theFunction: (value: Unwrap<Extract<ToEither<GenericInput>, EitherBoolFalsy>>) => GenericOutput
): GenericOutput | Exclude<ToEither<GenericInput>, EitherBoolFalsy>;

Curried signature

typescript
function whenIsBoolFalsy<
  const GenericInput extends unknown,
  const GenericOutput extends AnyValue | EscapeVoid
>(
  theFunction: (value: Unwrap<Extract<ToEither<GenericInput>, EitherBoolFalsy>>) => GenericOutput
): (input: GenericInput) => GenericOutput | Exclude<ToEither<GenericInput>, EitherBoolFalsy>;

Parameters

  • theFunction: Callback executed when the value is falsy.
  • input: Immediate input (optional in the curried version).

Return value

Result of the callback for falsy cases, otherwise the original truthy value.

See also

Released under the MIT license.