ts-data-forge
Version:
[](https://www.npmjs.com/package/ts-data-forge) [](https://www.npmjs.com/package/ts-data-forge) [;
*
* const mapped = Optional.map(numberOptional, (value) => value * 2);
*
* assert.deepStrictEqual(mapped, Optional.some(42));
*
* const mapToLength = Optional.map((text: string) => text.length);
*
* assert.deepStrictEqual(mapToLength(Optional.some('abc')), Optional.some(3));
*
* assert.deepStrictEqual(mapToLength(Optional.none), Optional.none);
* ```
*
* @template O The input `UnknownOptional` type.
* @template S2 The type of the value returned by the mapping function.
* @param optional The `Optional` to map.
* @param mapFn The function to apply to the value if it exists.
* @returns A new `Optional<S2>` resulting from the mapping, or
* `None` if the input was `None`.
*/
export declare function map<O extends UnknownOptional, S2>(optional: O, mapFn: (value: Unwrap<O>) => S2): Optional<S2>;
export declare function map<S, S2>(mapFn: (value: S) => S2): (optional: Optional<S>) => Optional<S2>;
//# sourceMappingURL=optional-map.d.mts.map