result.map
A success with its value transformed; a failure passes through unchanged.
Usage
Result.map<T, U>(r: Result<T>, f: (value: T) => U): Result<U>Parameters
rResult<T>The result to read.
f(value: T) => UAn infallible transform of the value.
Returns
For a success, { ok: true, value: f(value) } with the same diagnostics; a failure is returned as the same object.
Use instead
result.andThen: the step can itself fail and returns aResult
Example
Result.map(Result.ok(2), (n) => n * 10).value // → 20