Skip to content

whenHasInformationOtherwise

Exécute un callback pour les informations Either correspondantes et un callback otherwise pour toutes les entrées brutes restantes.

Exemple interactif

Syntaxe

Signature classique

typescript
function whenHasInformationOtherwise<
  GenericInput,
  GenericInformation,
  GenericOutput,
  GenericOtherwiseOutput
>(
  input: GenericInput,
  information: GenericInformation | GenericInformation[],
  theFunction: (value: UnwrappedMatchingInput) => GenericOutput,
  otherwiseFunction: (value: Exclude<RawInput, MatchingInput>) => GenericOtherwiseOutput
): GenericOutput | GenericOtherwiseOutput;

Signature currifiée

typescript
function whenHasInformationOtherwise<
  GenericInput,
  GenericInformation,
  GenericOutput,
  GenericOtherwiseOutput
>(
  information: GenericInformation | GenericInformation[],
  theFunction: (value: UnwrappedMatchingInput) => GenericOutput,
  otherwiseFunction: (value: Exclude<RawInput, MatchingInput>) => GenericOtherwiseOutput
): (input: GenericInput) => GenericOutput | GenericOtherwiseOutput;

Paramètres

  • information : Information littérale ou tableau d'informations à rechercher.
  • theFunction : Callback recevant le payload correspondant déballé.
  • otherwiseFunction : Callback recevant l'entrée brute originale qui ne correspond pas.
  • input : Valeur traitée 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.