@jiminp/tooltool
    Preparing search index...

    Function resultUnwrapOrElse

    • Extracts the value from a successful result, or computes a fallback from the error.

      Type Parameters

      • T
      • E = Error
      • U = T

      Parameters

      • result: Result<T, E>

        The result to unwrap.

      • fallback: (error: E) => U

        Computes a fallback from the error.

      Returns T | U

      The success value or the computed fallback.

      resultUnwrapOrElse({ ok: true, value: 42 }, () => 0);    // 42
      resultUnwrapOrElse({ ok: false, error: e }, () => -1); // -1