matchInformation
Pattern matching exhaustif sur l'information d'un Either. Chaque information possible de l'entrée doit être traitée.
Exemple interactif
Syntaxe
Signature classique
typescript
function matchInformation<
GenericInput extends unknown,
GenericMatcher extends ComputeMatcher<Extract<GenericInput, Right | Left>>
>(
input: GenericInput,
matcher: GenericMatcher
): ReturnType<GenericMatcher[keyof GenericMatcher]> | Exclude<GenericInput, Right | Left>;Signature currifiée
typescript
function matchInformation<
GenericInput extends unknown,
GenericMatcher extends ComputeMatcher<Extract<GenericInput, Right | Left>>
>(
matcher: GenericMatcher
): (input: GenericInput) => ReturnType<GenericMatcher[keyof GenericMatcher]> | Exclude<GenericInput, Right | Left>;Paramètres
matcher: Objet contenant un callback par clé d'information.input: Valeur à traiter immédiatement (optionnelle en style currifié).
Valeur de retour
- Si l'entrée est un
Either, renvoie le résultat du callback correspondant à son information. - Si l'entrée n'est pas un
Either, renvoie l'entrée telle quelle.
Voir aussi
matchInformationOtherwise- Variante non exhaustive avec fallback.whenHasInformation- Cible une information (ou une liste) avec callback.
