import * as tsplus_module_1 from "@effect/core/stream/Stream/operations/fromQueueWithShutdown";
import * as tsplus_module_2 from "@effect/core/io/Effect/operations/map";
import * as tsplus_module_3 from "@effect/core/io/Effect/operations/suspendSucceed";
import { DEFAULT_CHUNK_SIZE } from "@effect/core/stream/Stream/definition";
/**
 * Creates a stream from a subscription to a hub in the context of a scoped
 * effect. The scoped effect describes subscribing to receive messages from
 * the hub while the stream describes taking messages from the hub.
 *
 * @param maxChunkSize
 *   Maximum number of queued elements to put in one chunk in the stream.
 *
 * @tsplus static ets/Stream/Ops fromHubScoped
 */

export function fromHubScoped(hub, maxChunkSize = DEFAULT_CHUNK_SIZE, __tsplusTrace) {
  return tsplus_module_3.suspendSucceed(() => tsplus_module_2.map_(hub().subscribe, queue => tsplus_module_1.fromQueueWithShutdown(() => queue, maxChunkSize, __tsplusTrace), __tsplusTrace), __tsplusTrace);
}
//# sourceMappingURL=fromHubScoped.mjs.map