import { MergeDecision } from "@effect/core/stream/Channel/MergeDecision" /** * Feeds inputs to this sink until it yields a result, then switches over to * the provided sink until it yields a result, finally combining the two * results with `f`. * * @tsplus static effect/core/stream/Sink.Aspects zipWithPar * @tsplus pipeable effect/core/stream/Sink zipWithPar */ export function zipWithPar( that: Sink, f: (z: Z, z1: Z1) => Z2 ) { return (self: Sink): Sink => self.raceWith( that, (exit) => exit.fold>( (cause) => MergeDecision.done(Effect.failCause(cause)), (lz) => MergeDecision.await((exit) => exit.fold( (cause): Effect => Effect.failCause(cause), (rz) => Effect.sync(f(lz, rz)) ) ) ), (exit) => exit.fold>( (cause) => MergeDecision.done(Effect.failCause(cause)), (rz) => MergeDecision.await((exit) => exit.fold( (cause): Effect => Effect.failCause(cause), (lz) => Effect.sync(f(lz, rz)) ) ) ) ) }