// ets_tracing: off import type * as CK from "../../../../Collections/Immutable/Chunk/index.js" import * as CH from "../../Channel/index.js" import * as C from "../core.js" /** * Loops over the stream chunks concatenating the result of f */ export function loopOnChunks_( self: C.Stream, f: ( a: CK.Chunk ) => CH.Channel, unknown, E | E1, CK.Chunk, boolean> ): C.Stream { const loop: CH.Channel< R1, E | E1, CK.Chunk, unknown, E | E1, CK.Chunk, boolean > = CH.readWith( (chunk) => CH.chain_(f(chunk), (cont) => (cont ? loop : CH.end(false))), CH.fail, (_) => CH.succeed(false) ) return new C.Stream(self.channel[">>>"](loop)) } /** * Loops over the stream chunks concatenating the result of f * * @ets_data_first loopOnChunks_ */ export function loopOnChunks( f: ( a: CK.Chunk ) => CH.Channel, unknown, E | E1, CK.Chunk, boolean> ) { return (self: C.Stream) => loopOnChunks_(self, f) }