Overview
Maps aResultAsync<T, E> to ResultAsync<U, E> by applying a function to the contained Ok value. The Err value is left untouched.
Signature
Function to transform the Ok value. Can return either a value or a Promise.
ResultAsync<A, E> - A new ResultAsync with the transformed value
Usage
Basic transformation
Async transformation
Error handling
Key characteristics
The mapping function can be either synchronous or asynchronous with no impact on the return type - both return
ResultAsync.- Short-circuits on Err: If the ResultAsync is an Err, map is not executed
- Type safety: The transformed type is tracked through the chain
- Async support: Can handle both sync and async transformation functions
Related
mapErr
Transform the error value
andThen
Chain operations that return Results