Skip to content

unwrapLeftOrThrow

Unwraps the payload of a Left and throws a NotLeftError when the input is not Left.

Interactive example

Syntax

typescript
function unwrapLeftOrThrow<
  GenericInput extends unknown
>(
  input: GenericInput
): Unwrap<Extract<GenericInput, Left>>

Parameters

  • input: Value expected to be a Left.

Return value

Returns the unwrapped payload when the input is Left. Otherwise, the function throws E.NotLeftError.

See also

Released under the MIT license.