@pathmaker-digital/pmd-utilities - v2.2.6
    Preparing search index...

    Function unwrapResult

    • Unwraps a Result, returning the value if it is Ok. Throws the error if it is an Err.

      Type Parameters

      • T
      • E

      Parameters

      Returns T

      The value if res is Ok.

      The error if res is Err.

      const result = Ok("Success!");
      const value = unwrapResult(result); // "Success!"

      const errorResult = Err(new Error("Oops!"));
      unwrapResult(errorResult); // throws Error: "Oops!"