Skip to content

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

Signature currifiée

typescript
function matchWithStringOtherwise<Input extends Primitive<string>, Matcher, Output>(
  matcher: Matcher,
  otherwise: (value: UnhandledPrimitive) => Output
): (input: Input) => MatcherResult | Output

Paramè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 primitive Primitive, ConstrainedType ou NewType originale, 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

Diffusé sous licence MIT.