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.
The input Result or ResultAsync.
The result type returned by fn
.
pipe - It is recommended to use this function with the pipe function for better readability and composability.
andThrough<
R1
,R2
>(fn
): (result
) =>ResultFor
<R1
|R2
,InferSuccess
<R1
>,InferFailure
<R1
> |InferFailure
<R2
>>
Defined in: functions/and-through.ts:63
R1
extends ResultMaybeAsync
<any
, any
>
R2
extends ResultMaybeAsync
<any
, any
>
(a
) => R2
(
result
):ResultFor
<R1
|R2
,InferSuccess
<R1
>,InferFailure
<R1
> |InferFailure
<R2
>>
R1
ResultFor
<R1
| R2
, InferSuccess
<R1
>, InferFailure
<R1
> | InferFailure
<R2
>>
andThrough<
F
>(fn
): <R1
>(result
) =>ResultFor
<R1
|ReturnType
<F
>,InferSuccess
<R1
>,InferFailure
<R1
> |InferFailure
<F
>>
Defined in: functions/and-through.ts:64
F
extends (a
) => ResultMaybeAsync
<any
, any
>
F
<
R1
>(result
):ResultFor
<R1
|ReturnType
<F
>,InferSuccess
<R1
>,InferFailure
<R1
> |InferFailure
<F
>>
R1
extends ResultMaybeAsync
<Parameters
<F
>[0
], any
>
R1
ResultFor
<R1
| ReturnType
<F
>, InferSuccess
<R1
>, InferFailure
<R1
> | InferFailure
<F
>>