ts-data-forge
Version:
[](https://www.npmjs.com/package/ts-data-forge) [](https://www.npmjs.com/package/ts-data-forge) [;
*
* const errResult = Result.err('failure');
*
* assert.isTrue(Result.unwrapErrOr(okResult, 'default') === 'default');
*
* assert.isTrue(Result.unwrapErrOr(errResult, 'default') === 'failure');
*
* const unwrapError = Result.unwrapErrOr('fallback error');
*
* assert.isTrue(unwrapError(Result.err('boom')) === 'boom');
*
* assert.isTrue(unwrapError(Result.ok('no error')) === 'fallback error');
* ```
*
* @template R The `UnknownResult` type to unwrap.
* @template D The type of the default value.
* @param result The `Result` to unwrap.
* @param defaultValue The value to return if `result` is `Result.Ok`.
* @returns The error value if `Result.Err`, otherwise `defaultValue`.
*/
export declare function unwrapErrOr<R extends UnknownResult, D>(result: R, defaultValue: D): D | UnwrapErr<R>;
export declare function unwrapErrOr<D>(defaultValue: D): <S, E>(result: Result<S, E>) => D | E;
//# sourceMappingURL=result-unwrap-err-or.d.mts.map