import { SinkInternal } from "@effect/core/stream/Sink/operations/_internal/SinkInternal" /** * A sink that executes the provided effectful function for every element fed * to it. * * @tsplus static effect/core/stream/Sink.Ops forEach */ export function forEach( f: (input: In) => Effect ): Sink { const process: Channel< R, E, Chunk, unknown, E, never, void > = Channel.readWithCause( (chunk: Chunk) => Channel.fromEffect(Effect.forEachDiscard(chunk, f)).flatMap(() => process), (cause) => Channel.failCause(cause), () => Channel.unit ) return new SinkInternal(process) }