import { concreteSink, SinkInternal } from "@effect/core/stream/Sink/operations/_internal/SinkInternal" /** * Summarize a sink by running an effect when the sink starts and again when * it completes * * @tsplus static effect/core/stream/Sink.Aspects summarized * @tsplus pipeable effect/core/stream/Sink summarized */ export function summarized( summary: Effect, f: (x: B, y: B) => C ) { return ( self: Sink ): Sink => new SinkInternal( Channel.fromEffect(summary).flatMap((start) => { concreteSink(self) return self.channel.flatMap((done) => Channel.fromEffect(summary).map((end) => [done, f(start, end)] as const) ) }) ) }