Skip to content

matchWithNumberOtherwise ​

matchWithNumberOtherwise() handles selected values of a Clean number primitive. Raw number 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 matchWithNumberOtherwise<Input extends Primitive<number>, Matcher, Output>(
  input: Input,
  matcher: Matcher,
  otherwise: (value: UnhandledPrimitive) => Output
): MatcherResult | Output

Curried signature ​

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

Parameters ​

  • input: a Clean number primitive with literal values.
  • matcher: a partial object indexed by raw values from the primitive. Unknown keys are rejected.
  • otherwise: receives the original Primitive, ConstrainedType, or NewType, narrowed to values without a handler.

Return value ​

The selected handler result, or the otherwise result for an unhandled wrapped value.

See also ​

Released under the MIT license.