Extracts the value from a successful result, or computes a fallback from the error.
The result to unwrap.
Called once, only for Err, with the original failure value.
Err
The success value or the computed fallback.
Returns falsy and nullish success values unchanged. The fallback runs synchronously; exceptions it throws propagate to the caller.
resultUnwrapOrElse({ ok: true, value: 42 }, () => 0); // 42resultUnwrapOrElse({ ok: false, error: e }, () => -1); // -1 Copy
resultUnwrapOrElse({ ok: true, value: 42 }, () => 0); // 42resultUnwrapOrElse({ ok: false, error: e }, () => -1); // -1
Extracts the value from a successful result, or computes a fallback from the error.