neverthrow icon indicating copy to clipboard operation
neverthrow copied to clipboard

Feature Proposal: Add unwrapOrElse method to Result

Open JesseGovindan opened this issue 5 months ago • 4 comments

Introduce a new instance method on Result and ResultAsync

unwrapOrElse<U>(op: (err: E) => U): T | U
  • Success (Ok): returns the contained T.
  • Failure (Err): calls the provided callback op with the error E and returns the callback’s return value.

This would prevent having to use .match with a callback such as (value) => value, in the first parameter.

JesseGovindan avatar Jul 31 '25 08:07 JesseGovindan