Chains another Result-producing computation and merges its success value into the existing object under the specified key.
{ [name]: nextSuccess }
.This is useful for building up objects in a compositional and type-safe way, especially in validation or data-fetching pipelines.
The key to assign the result of the fn
computation.
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.
bind<
N
,R1
,R2
>(name
,fn
): (result
) =>InferSuccess
<R1
> extendsobject
?ResultFor
<R1
|R2
, { [K in string | number | symbol]: K extends keyof InferSuccess<InferSuccess<R1>> ? InferSuccess<InferSuccess<R1>>[K<K>] : InferSuccess<R2> },InferFailure
<R1
> |InferFailure
<R2
>> :unknown
Defined in: functions/bind.ts:64
N
extends string
R1
extends ResultMaybeAsync
<any
, any
>
R2
extends ResultMaybeAsync
<any
, any
>
N
(a
) => R2
(
result
):InferSuccess
<R1
> extendsobject
?ResultFor
<R1
|R2
, { [K in string | number | symbol]: K extends keyof InferSuccess<InferSuccess<R1>> ? InferSuccess<InferSuccess<R1>>[K<K>] : InferSuccess<R2> },InferFailure
<R1
> |InferFailure
<R2
>> :unknown
R1
InferSuccess
<R1
> extends object
? ResultFor
<R1
| R2
, { [K in string | number | symbol]: K extends keyof InferSuccess<InferSuccess<R1>> ? InferSuccess<InferSuccess<R1>>[K<K>] : InferSuccess<R2> }, InferFailure
<R1
> | InferFailure
<R2
>> : unknown
bind<
N
,F
>(name
,fn
): <R1
>(result
) =>Parameters
<F
>[0
] extendsobject
?ResultFor
<R1
|ReturnType
<F
>, { [K in string | number | symbol]: K extends keyof any[any] ? any[any][K<K>] : InferSuccess<F> },InferFailure
<R1
> |InferFailure
<F
>> :unknown
Defined in: functions/bind.ts:65
N
extends string
F
extends (a
) => ResultMaybeAsync
<any
, any
>
N
F
<
R1
>(result
):Parameters
<F
>[0
] extendsobject
?ResultFor
<R1
|ReturnType
<F
>, { [K in string | number | symbol]: K extends keyof any[any] ? any[any][K<K>] : InferSuccess<F> },InferFailure
<R1
> |InferFailure
<F
>> :unknown
R1
extends ResultMaybeAsync
<Parameters
<F
>[0
], any
>
R1
Parameters
<F
>[0
] extends object
? ResultFor
<R1
| ReturnType
<F
>, { [K in string | number | symbol]: K extends keyof any[any] ? any[any][K<K>] : InferSuccess<F> }, InferFailure
<R1
> | InferFailure
<F
>> : unknown