ts-data-forge
Version:
[](https://www.npmjs.com/package/ts-data-forge) [](https://www.npmjs.com/package/ts-data-forge) [;
*
* const errMessage = Result.err('error');
*
* const doubled = Result.map(okNumber, (value) => value * 2);
*
* const untouchedError = Result.map(errMessage, (value: number) => value * 2);
*
* assert.deepStrictEqual(doubled, Result.ok(10));
*
* assert.deepStrictEqual(untouchedError, errMessage);
*
* const mapToLength = Result.map((text: string) => text.length);
*
* assert.deepStrictEqual(mapToLength(Result.ok('abc')), Result.ok(3));
*
* assert.deepStrictEqual(mapToLength(Result.err('bad')), Result.err('bad'));
* ```
*
* @template R The input `UnknownResult` type.
* @template S2 The type of the success value returned by the mapping
* function.
* @param result The `Result` to map.
* @param mapFn The function to apply to the success value if present.
* @returns A new `Result<S2, UnwrapErr<R>>`.
*/
export declare function map<R extends UnknownResult, S2>(result: R, mapFn: (value: UnwrapOk<R>) => S2): Result<S2, UnwrapErr<R>>;
export declare function map<S, S2>(mapFn: (value: S) => S2): <E>(result: Result<S, E>) => Result<S2, E>;
//# sourceMappingURL=result-map.d.mts.map