matchWithStringOtherwise
matchWithStringOtherwise() handles selected values of a Clean string primitive. Raw string values form the matcher keys. Missing cases are sent to otherwise, which receives the original primitive narrowed to the remaining values.
Interactive example
Syntax
Classic signature
typescript
function matchWithStringOtherwise<Input extends Primitive<string>, Matcher, Output>(
input: Input,
matcher: Matcher,
otherwise: (value: UnhandledPrimitive) => Output
): MatcherResult | OutputCurried signature
typescript
function matchWithStringOtherwise<Input extends Primitive<string>, Matcher, Output>(
matcher: Matcher,
otherwise: (value: UnhandledPrimitive) => Output
): (input: Input) => MatcherResult | OutputParameters
input: a Clean string primitive with literal values.matcher: a partial object indexed by raw values from the primitive. Unknown keys are rejected.otherwise: receives the originalPrimitive,ConstrainedType, orNewType, narrowed to values without a handler.
Return value
The selected handler result, or the otherwise result for an unhandled wrapped value.
See also
matchWithString- Exhaustive primitive matching.matchWithNumberOtherwise- Number primitive equivalent.
