import { SinkInternal } from "@effect/core/stream/Sink/operations/_internal/SinkInternal" /** * A sink that executes the provided effectful function for every chunk fed to * it until `f` evaluates to `false`. * * @tsplus static effect/core/stream/Sink.Ops forEachChunkWhile */ export function forEachChunkWhile( f: (input: Chunk) => Effect ): Sink { const reader: Channel< R, E, Chunk, unknown, E, Chunk, void > = Channel.readWith( (input: Chunk) => Channel.fromEffect(f(input)).flatMap((cont) => (cont ? reader : Channel.unit)), (err) => Channel.fail(err), () => Channel.unit ) return new SinkInternal(reader) }