Chains the next computation using the success value of a Result or ResultAsync. If the original result is a Failure, it is returned unchanged. Otherwise, the provided function is called, and its result is returned as-is.
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.
andThen<
R1
,R2
>(fn
): (result
) =>ResultFor
<R1
|R2
,InferSuccess
<R2
>,InferFailure
<R1
> |InferFailure
<R2
>>
Defined in: functions/and-then.ts:51
R1
extends ResultMaybeAsync
<any
, any
>
R2
extends ResultMaybeAsync
<any
, any
>
(a
) => R2
(
result
):ResultFor
<R1
|R2
,InferSuccess
<R2
>,InferFailure
<R1
> |InferFailure
<R2
>>
R1
ResultFor
<R1
| R2
, InferSuccess
<R2
>, InferFailure
<R1
> | InferFailure
<R2
>>
andThen<
F
>(fn
): <R1
>(result
) =>ResultFor
<R1
|ReturnType
<F
>,InferSuccess
<F
>,InferFailure
<R1
> |InferFailure
<F
>>
Defined in: functions/and-then.ts:52
F
extends (a
) => ResultMaybeAsync
<any
, any
>
F
<
R1
>(result
):ResultFor
<R1
|ReturnType
<F
>,InferSuccess
<F
>,InferFailure
<R1
> |InferFailure
<F
>>
R1
extends ResultMaybeAsync
<Parameters
<F
>[0
], any
>
R1
ResultFor
<R1
| ReturnType
<F
>, InferSuccess
<F
>, InferFailure
<R1
> | InferFailure
<F
>>