// tracing: off
import * as C from "../../Cause"
import { pipe } from "../../Function"
import * as Q from "../../Queue"
import * as T from "../_internal/effect"
import * as Pull from "../Pull"
import { repeatEffectChunkOption } from "./repeatEffectChunkOption"
/**
 * Creates a stream from a {@link XQueue} of values
 */

export function fromQueue(queue) {
  return repeatEffectChunkOption(
    T.catchAllCause_(Q.takeBetween_(queue, 1, Number.MAX_SAFE_INTEGER), (c) =>
      T.chain_(Q.isShutdown(queue), (down) =>
        down && C.interrupted(c) ? Pull.end : Pull.halt(c)
      )
    )
  )
}
//# sourceMappingURL=fromQueue.js.map
