Skip to content

matchInformation

Exhaustive pattern matching on Either information. Every information case from the input must be handled.

Interactive example

Syntax

Classic signature

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

Curried signature

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

Parameters

  • matcher: Object with one callback per information key.
  • input: Value to process immediately (optional in curried style).

Return value

  • If input is an Either, returns the callback result matching its information.
  • If input is not an Either, returns input as-is.

See also

Released under the MIT license.