Evercatch - v0.9.0
    Preparing search index...

    Function unwrapOr

    • Unwraps a Result, returning a fallback value if it contains an error.

      Type Parameters

      • T

        The type of the value.

      • E = Error

        The type of the error.

      Parameters

      • result: Result<T, E>

        The Result to unwrap.

      • fallback: T

        The value to return when the result contains an error.

      Returns T

      The unwrapped value or the fallback.

      const value = unwrapOr(ok(42), 0);
      console.log(value); // 42
      const value = unwrapOr(err(new Error("Oops")), 0);
      console.log(value); // 0