# map

Transforms values before they reach the sink using a pure function.

## Signatures

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

## Why

Contramapping adapts a consumer to a new input without changing the producer or allocating an
intermediate Fx.

## Ownership and lifetime

Mapping is synchronous, preserves one-for-one input order, and acquires no resources. Thrown
exceptions are defects. The wrapped sink still owns its callback effects and service needs.

## Examples

```ts
import { Effect } 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("Received:", value))
  )

  // Map string inputs to numbers
  const mapped = Sink.map(sink, (str: string) => parseInt(str))

  // Run an Fx with the mapped sink
  yield* Fx.fromIterable(["1", "2", "3"]).run(mapped)
  // Output: "Received: 1", "Received: 2", "Received: 3"
})
```
