import { concreteStream, StreamInternal } from "@effect/core/stream/Stream/operations/_internal/StreamInternal" /** * Keeps some of the errors, and terminates the fiber with the rest, using the * specified function to convert the `E` into a `Throwable`. * * @tsplus static effect/core/stream/Stream.Aspects refineOrDieWith * @tsplus pipeable effect/core/stream/Stream refineOrDieWith */ export function refineOrDieWith( pf: (e: E) => Maybe, f: (e: E) => unknown ) { return (self: Stream): Stream => { concreteStream(self) return new StreamInternal( self.channel.catchAll((e) => pf(e).fold( Channel.failCauseSync(Cause.die(f(e))), (e2) => Channel.fail(e2) ) ) ) } }