Skip to content

whenIsNullableFilledOtherwise ​

Exécute un callback pour les valeurs NullableFilled et un callback otherwise pour toutes les entrées brutes restantes.

Exemple interactif ​

Syntaxe ​

Signature classique ​

typescript
function whenIsNullableFilledOtherwise<
  GenericInput,
  GenericOutput,
  GenericOtherwiseOutput
>(
  input: GenericInput,
  theFunction: (value: UnwrappedMatchingInput) => GenericOutput,
  otherwiseFunction: (value: Exclude<RawInput, MatchingInput>) => GenericOtherwiseOutput
): GenericOutput | GenericOtherwiseOutput;

Signature currifiée ​

typescript
function whenIsNullableFilledOtherwise<
  GenericInput,
  GenericOutput,
  GenericOtherwiseOutput
>(
  theFunction: (value: UnwrappedMatchingInput) => GenericOutput,
  otherwiseFunction: (value: Exclude<RawInput, MatchingInput>) => GenericOtherwiseOutput
): (input: GenericInput) => GenericOutput | GenericOtherwiseOutput;

Paramètres ​

  • theFunction : Callback recevant la valeur déballée lorsque la condition correspond.
  • otherwiseFunction : Callback recevant l'entrée brute originale lorsque la condition ne correspond pas.
  • input : Valeur brute ou Either traité immédiatement, ou plus tard avec la forme currifiée.

Valeur de retour ​

Renvoie le résultat du callback correspondant lorsque la condition réussit ; sinon, renvoie le résultat de otherwiseFunction. Le callback otherwise reçoit toujours l'entrée brute originale.

Voir aussi ​

Diffusé sous licence MIT.