// ets_tracing: off import "../../Operator/index.js" import * as Chunk from "../../Collections/Immutable/Chunk/index.js" import * as T from "../../Effect/index.js" import * as P from "../../Promise/index.js" import type * as MQ from "../../Support/MutableQueue/index.js" import type * as HB from "./Hub.js" /** * Unsafely completes a promise with the specified value. */ export function unsafeCompletePromise(promise: P.Promise, a: A): void { P.unsafeDone(T.succeed(a))(promise) } /** * Unsafely offers the specified values to a queue. */ export function unsafeOfferAll( queue: MQ.MutableQueue, as: Iterable ): Chunk.Chunk { return queue.offerAll(as) } /** * Unsafely polls all values from a queue. */ export function unsafePollAllQueue(queue: MQ.MutableQueue): Chunk.Chunk { return queue.pollUpTo(Number.MAX_SAFE_INTEGER) } /** * Unsafely polls all values from a subscription. */ export function unsafePollAllSubscription( subscription: HB.Subscription ): Chunk.Chunk { return subscription.pollUpTo(Number.MAX_SAFE_INTEGER) } /** * Unsafely polls the specified number of values from a subscription. */ export function unsafePollN( subscription: HB.Subscription, max: number ): Chunk.Chunk { return subscription.pollUpTo(max) } /** * Unsafely publishes the specified values to a hub. */ export function unsafePublishAll(hub: HB.Hub, as: Iterable): Chunk.Chunk { return hub.publishAll(as) } /** * Unsafely removes the specified item from a queue. */ export function unsafeRemove(queue: MQ.MutableQueue, a: A): void { unsafeOfferAll( queue, Chunk.filter_(unsafePollAllQueue(queue), (_) => _ !== a) ) }