ts-data-forge
Version:
[](https://www.npmjs.com/package/ts-data-forge) [](https://www.npmjs.com/package/ts-data-forge) [` when you have a sensible fallback
* value.
*
* @example
*
* ```ts
* const withValue = Optional.some(5);
*
* const withoutValue = Optional.none as Optional<number>;
*
* assert.isTrue(Optional.unwrapOr(withValue, 0) === 5);
*
* assert.isTrue(Optional.unwrapOr(withoutValue, 0) === 0);
*
* const unwrapWithDefault = Optional.unwrapOr(10);
*
* assert.isTrue(unwrapWithDefault(Optional.some(3)) === 3);
*
* assert.isTrue(unwrapWithDefault(Optional.none) === 10);
* ```
*
* @template O The `UnknownOptional` type to unwrap.
* @template D The type of the default value.
* @param optional The `Optional` to unwrap.
* @param defaultValue The value to return if `optional` is `None`.
* @returns The contained value if `Some`, otherwise `defaultValue`.
*/
export declare function unwrapOr<O extends UnknownOptional, D>(optional: O, defaultValue: D): D | Unwrap<O>;
export declare function unwrapOr<S, D>(defaultValue: D): (optional: Optional<S>) => D | S;
//# sourceMappingURL=optional-unwrap-or.d.mts.map