/** * @tsplus static effect/core/stream/Channel.Aspects contramapInEffect * @tsplus pipeable effect/core/stream/Channel contramapInEffect */ export function contramapInEffect< Env1, InErr, InElem0, InElem >(f: (a: InElem0) => Effect) { return ( self: Channel ): Channel => contramapInEffectReader(f) >> self } function contramapInEffectReader( f: (a: InElem0) => Effect ): Channel { return Channel.readWith( (inElem) => Channel.fromEffect(f(inElem)).flatMap((elem) => Channel.write(elem)).flatMap(() => contramapInEffectReader(f) ), (inErr) => Channel.fail(inErr), (inDone) => Channel.succeed(inDone) ) }