Chains the next computation using the error value of a Result or ResultAsync. If the original result is a Success, 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.
orElse<
R1
,R2
>(fn
): (result
) =>ResultFor
<R1
|R2
,InferSuccess
<R1
> |InferSuccess
<R2
>,InferFailure
<R2
>>
Defined in: functions/or-else.ts:51
R1
extends ResultMaybeAsync
<any
, any
>
R2
extends ResultMaybeAsync
<any
, any
>
(a
) => R2
(
result
):ResultFor
<R1
|R2
,InferSuccess
<R1
> |InferSuccess
<R2
>,InferFailure
<R2
>>
R1
ResultFor
<R1
| R2
, InferSuccess
<R1
> | InferSuccess
<R2
>, InferFailure
<R2
>>
orElse<
F
>(fn
): <R1
>(result
) =>ResultFor
<R1
|ReturnType
<F
>,InferSuccess
<R1
> |InferSuccess
<F
>,InferFailure
<F
>>
Defined in: functions/or-else.ts:52
F
extends (a
) => ResultMaybeAsync
<any
, any
>
F
<
R1
>(result
):ResultFor
<R1
|ReturnType
<F
>,InferSuccess
<R1
> |InferSuccess
<F
>,InferFailure
<F
>>
R1
extends ResultMaybeAsync
<any
, Parameters
<F
>[0
]>
R1
ResultFor
<R1
| ReturnType
<F
>, InferSuccess
<R1
> | InferSuccess
<F
>, InferFailure
<F
>>