/** * @tsplus static effect/core/stream/Channel.Ops fromQueue */ export function fromQueue( queue: Dequeue, Elem>> ): Channel { return Channel.suspend(fromQueueInternal(queue)) } function fromQueueInternal( queue: Dequeue, Elem>> ): Channel { return Channel.fromEffect(queue.take).flatMap((either) => either.fold( (exit) => exit.fold( (cause) => Channel.failCause(cause), (done): Channel => Channel.succeed(done) ), (elem) => Channel.write(elem) .flatMap(() => fromQueueInternal(queue)) ) ) }