ts-data-forge
Version:
[](https://www.npmjs.com/package/ts-data-forge) [](https://www.npmjs.com/package/ts-data-forge) [;
*
* const errValue = Result.err('fail');
*
* assert.isTrue(Result.unwrapOkOr(okValue, 0) === 10);
*
* assert.isTrue(Result.unwrapOkOr(errValue, 0) === 0);
*
* const unwrapWithDefault = Result.unwrapOkOr(5);
*
* assert.isTrue(unwrapWithDefault(Result.ok(3)) === 3);
*
* assert.isTrue(unwrapWithDefault(Result.err('no data')) === 5);
* ```
*
* @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.Err`.
* @returns The success value if `Result.Ok`, otherwise `defaultValue`.
*/
export declare function unwrapOkOr<R extends UnknownResult, D>(result: R, defaultValue: D): D | UnwrapOk<R>;
export declare function unwrapOkOr<S, D>(defaultValue: D): <E>(result: Result<S, E>) => D | S;
//# sourceMappingURL=result-unwrap-ok-or.d.mts.map