For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /reference/function/tap.md.

tap

Returns a function that runs a side-effect and returns the value unchanged.

Useful for debugging inside flow pipelines without breaking the chain.

const process = flow(
  fetchUsers,
  tap(users => console.log('count:', users.length)),
  filterActive,
)

Usage

tap<T>(fn: (value: T) => unknown)

Returns a function that runs a side-effect and returns the value unchanged.

Useful for debugging inside flow pipelines without breaking the chain.

import { tap } from 'massaman'
// or:  import { tap } from 'massaman/function'

const process = flow(
  fetchUsers,
  tap(users => console.log('count:', users.length)),
  filterActive,
)

Parameters

fn(value: T) => unknownrequired

the side-effecting function to run with each value.

Returns

a function that runs fn and returns its input unchanged.

(value: T) => T