import { concreteStream, StreamInternal } from "@effect/core/stream/Stream/operations/_internal/StreamInternal" /** * Maps over elements of the stream with the specified effectful function, * executing up to `n` invocations of `f` concurrently. Transformed elements * will be emitted in the original order. * * @note This combinator destroys the chunking structure. It's recommended to use * rechunk afterwards. * * @tsplus static effect/core/stream/Stream.Aspects mapEffectPar * @tsplus pipeable effect/core/stream/Stream mapEffectPar */ export function mapEffectPar( n: number, f: (a: A) => Effect ) { return (self: Stream): Stream => { concreteStream(self) return new StreamInternal( self.channel .concatMap(Channel.writeChunk) .mapOutEffectPar(n, f) .mapOut(Chunk.single) ) } }