Skip to content

unwrapRightOrThrow

Unwraps the payload of a Right and throws a NotRightError when the input is not Right.

Interactive example

Syntax

typescript
function unwrapRightOrThrow<
  GenericInput extends unknown
>(
  input: GenericInput
): Unwrap<Extract<GenericInput, Right>>

Parameters

  • input: Value expected to be a Right.

Return value

Returns the unwrapped payload when the input is Right. Otherwise, the function throws E.NotRightError.

See also

Released under the MIT license.