# filterMap

Filters and transforms values before they reach the sink using a function that returns an `Option`.

## Signatures

```ts
export declare function filterMap<A, E, R, B>(sink: Sink<A, E, R>, f: (b: B) => Option.Option<A>): Sink<B, E, R>;
```

## Why

Selection and transformation happen at the consumer boundary without constructing another Fx.

## Ownership and lifetime

Inputs are inspected synchronously in arrival order. `Some` invokes the wrapped sink once;
`None` invokes it zero times. The adapter acquires no resources and failures pass through.

## Examples

```ts
import { Effect, Option } from "effect"
import * as Sink from "@typed/fx/Sink"
import { Fx } from "@typed/fx"

const program = Effect.gen(function* () {
  const sink = Sink.make(
    (cause) => Effect.void,
    (value: number) => Effect.sync(() => console.log("Even:", value))
  )

  // Only pass through even numbers
  const filtered = Sink.filterMap(sink, (n: number) =>
    n % 2 === 0 ? Option.some(n) : Option.none()
  )

  yield* Fx.fromIterable([1, 2, 3, 4, 5]).run(filtered)
  // Output: "Even: 2", "Even: 4"
})
```
