matchWithStringOtherwise
matchWithStringOtherwise() traite certaines valeurs d’une primitive Clean string. Les valeurs string brutes forment les clés du matcher. Les cas manquants sont transmis à otherwise, qui reçoit la primitive originale affinée sur les valeurs restantes.
Exemple interactif
Syntaxe
Signature classique
typescript
function matchWithStringOtherwise<Input extends Primitive<string>, Matcher, Output>(
input: Input,
matcher: Matcher,
otherwise: (value: UnhandledPrimitive) => Output
): MatcherResult | OutputSignature currifiée
typescript
function matchWithStringOtherwise<Input extends Primitive<string>, Matcher, Output>(
matcher: Matcher,
otherwise: (value: UnhandledPrimitive) => Output
): (input: Input) => MatcherResult | OutputParamètres
input: une primitive Clean string contenant des valeurs littérales.matcher: un objet partiel indexé par les valeurs brutes de la primitive. Les clés inconnues sont refusées.otherwise: reçoit la primitivePrimitive,ConstrainedTypeouNewTypeoriginale, affinée sur les valeurs sans handler.
Valeur de retour
Le résultat du handler sélectionné, ou celui d’otherwise pour une valeur wrappée non traitée.
Voir aussi
matchWithString- Matching exhaustif de primitive.matchWithNumberOtherwise- Équivalent pour une primitive number.
