Skip to content

whenIsBoolTruthy

Callback exécuté uniquement pour les valeurs EitherBoolTruthy. 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>, EitherBoolTruthy>>) => GenericOutput
): GenericOutput | Exclude<ToEither<GenericInput>, EitherBoolTruthy>;

Signature currifiée

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

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 (EitherBoolFalsy).

Voir aussi

Diffusé sous licence MIT.