import * as O from "../../Option"
import * as T from "../_internal/effect"
import * as M from "../_internal/managed"
import * as Pull from "../Pull"
import { Stream } from "./definitions"
/**
 * Halts the stream with given cause if it does not produce a value after d duration.
 */

export function timeoutErrorCause(cause) {
  return (d) => (self) =>
    new Stream(
      M.map_(self.proc, (next) =>
        T.chain_(
          T.timeout_(next, d),
          O.fold(
            () => Pull.halt(cause),
            (a) => Pull.emitChunk(a)
          )
        )
      )
    )
}
//# sourceMappingURL=timeoutErrorCause.js.map
