Package: effect
Module: Result
Runs a side-effect on the success value without altering the Result.
Details
Success, calls f with the value (return value is ignored)Failure, f is not calledResult unchanged (same reference)Example (Logging a success value)
import { pipe, Result } from "effect"
const result = pipe(
Result.succeed(42),
Result.tap((n) => console.log("Got:", n))
)
// Output: "Got: 42"
console.log(Result.isSuccess(result))
// Output: true
See
map to transform the success valueSignature
declare const tap: { <A>(f: (a: A) => void): <E>(self: Result<A, E>) => Result<A, E>; <A, E>(self: Result<A, E>, f: (a: A) => void): Result<A, E>; }
Since v4.0.0