Import
import { Sink } from "@typed/fx";Access Sink.map through the imported Sink export. Its declaration below describes the member.
This public exposure is a re-export. Its import path is supported; declaration documentation is shared with the other public exposures below.
Signatures
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
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"
})Other public imports
These import paths expose the same declaration. Each page retains its own public name and signature.