Skip to main content

Overview

The andTee and orTee methods allow you to perform side effects on Ok or Err values without affecting the Result. Useful for logging, metrics, or other operations that shouldn’t fail your main logic.

Signatures

andTee

(t: T) => unknown
required
Function to execute if Ok. Can be sync or async. Errors are caught and ignored.

orTee

(e: E) => unknown
required
Function to execute if Err. Can be sync or async. Errors are caught and ignored.
Returns: The original ResultAsync unchanged

Usage

Logging success

Logging errors

Metrics collection

Audit trail

Error handling in tee functions

If the tee function throws an error or rejects, the error is caught and ignored. The original Result passes through unchanged.

Key characteristics

Comparison with through methods

through-methods

Side effects that can fail the chain

Result tee methods

Synchronous version