Skip to content

whenIsBoolTruthy

Callback exécuté uniquement pour les valeurs BoolTruthy. Sinon, la valeur initiale est renvoyée.

Exemple interactif

Syntaxe

Signature classique

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>;

Signature currifiée

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>;

Paramètres

  • theFunction : Fonction exécutée seulement quand la valeur est truthy.
  • input : Valeur ou Either à traiter (optionnel dans la version currifiée).

Valeur de retour

Le résultat de theFunction pour les truthy, sinon la valeur originale (BoolFalsy).

Voir aussi

Diffusé sous licence MIT.