Runs an additional computation using the success value of a Result or ResultAsync,
but returns the original result if the additional computation is successful.
If either the original result or the side effect result is a Failure, that failure is returned.
Useful for running validations or side effects without altering the main result on success.
Runs an additional computation using the success value of a Result or ResultAsync, but returns the original result if the additional computation is successful.
If either the original result or the side effect result is a Failure, that failure is returned. Useful for running validations or side effects without altering the main result on success.
Type Param: R1
The input Result or ResultAsync.
Type Param: R2
The result type returned by
fn
.Example: Success Case
Example: Failure Case (input is a Failure)
Example: Failure Case (function returns a Failure)
See
pipe - It is recommended to use this function with the pipe function for better readability and composability.