// ets_tracing: off import * as CK from "../../../../Collections/Immutable/Chunk/index.js" import * as CH from "../../Channel/index.js" import * as C from "../core.js" /** * Returns a stream made of the concatenation in strict order of all the streams * produced by passing each element of this stream to `f` */ export function chain_( self: C.Stream, f: (o: O) => C.Stream ): C.Stream { return new C.Stream( CH.concatMap_(self.channel, (o) => CK.reduce_( CK.map_(o, (x) => f(x).channel), CH.unit as CH.Channel, unknown>, (s, a) => CH.chain_(s, () => a) ) ) ) } /** * Returns a stream made of the concatenation in strict order of all the streams * produced by passing each element of this stream to `f` * * @ets_data_first chain_ */ export function chain( f: (o: O) => C.Stream ): (self: C.Stream) => C.Stream { return (self) => chain_(self, f) }