Function: inspect()
Executes a side effect function on the success value of a Result or ResultAsync, without modifying the original result. This is useful for debugging, logging, or performing other side effects while maintaining the original value and error state.
inspect(fn)Select a case to follow its pathType Param
R1
The input Result or ResultAsync.
Type Param
R2
The return type of the inspection function.
Examples
Success Case
Failure Case
See
pipe - It is recommended to use this function with the pipe function for better readability and composability.
Call Signature
inspect<
R1,R2>(fn): (result) =>ResultFor<R1|R2,InferSuccess<R1>,InferFailure<R1>>
Type Parameters
R1
R1 extends ResultMaybeAsync<any, any>
R2
R2
Parameters
fn
(a) => R2
Returns
(result) => ResultFor<R1 | R2, InferSuccess<R1>, InferFailure<R1>>
Call Signature
inspect<
F>(fn): <R1>(result) =>ResultFor<R1|ReturnType<F>,InferSuccess<R1>,InferFailure<R1>>
Type Parameters
F
F extends (a) => unknown
Parameters
fn
F
Returns
<R1>(result) => ResultFor<R1 | ReturnType<F>, InferSuccess<R1>, InferFailure<R1>>
