Hyperlinkv0.8.0-beta.28

Channel

Channel.toQueueArrayconsteffect/Channel.ts:8278
(
  options:
    | { readonly capacity: "unbounded" }
    | {
        readonly capacity: number
        readonly strategy?: "dropping" | "sliding" | "suspend" | undefined
      }
): <OutElem, OutErr, OutDone, Env>(
  self: Channel<
    Arr.NonEmptyReadonlyArray<OutElem>,
    OutErr,
    OutDone,
    unknown,
    unknown,
    unknown,
    Env
  >
) => Effect.Effect<
  Queue.Dequeue<OutElem, OutErr | Cause.Done>,
  never,
  Env | Scope.Scope
>
<OutElem, OutErr, OutDone, Env>(
  self: Channel<
    Arr.NonEmptyReadonlyArray<OutElem>,
    OutErr,
    OutDone,
    unknown,
    unknown,
    unknown,
    Env
  >,
  options:
    | { readonly capacity: "unbounded" }
    | {
        readonly capacity: number
        readonly strategy?: "dropping" | "sliding" | "suspend" | undefined
      }
): Effect.Effect<
  Queue.Dequeue<OutElem, OutErr | Cause.Done>,
  never,
  Env | Scope.Scope
>

Creates a scoped queue and forks an array-emitting channel to feed it.

Details

Each element inside emitted non-empty arrays is offered to the queue. Channel completion and failure are signaled through the queue. The queue is shut down when the surrounding scope closes.

destructors
Source effect/Channel.ts:827841 lines
export const toQueueArray: {
  (
    options: {
      readonly capacity: "unbounded"
    } | {
      readonly capacity: number
      readonly strategy?: "dropping" | "sliding" | "suspend" | undefined
    }
  ): <OutElem, OutErr, OutDone, Env>(
    self: Channel<Arr.NonEmptyReadonlyArray<OutElem>, OutErr, OutDone, unknown, unknown, unknown, Env>
  ) => Effect.Effect<Queue.Dequeue<OutElem, OutErr | Cause.Done>, never, Env | Scope.Scope>
  <OutElem, OutErr, OutDone, Env>(
    self: Channel<Arr.NonEmptyReadonlyArray<OutElem>, OutErr, OutDone, unknown, unknown, unknown, Env>,
    options: {
      readonly capacity: "unbounded"
    } | {
      readonly capacity: number
      readonly strategy?: "dropping" | "sliding" | "suspend" | undefined
    }
  ): Effect.Effect<Queue.Dequeue<OutElem, OutErr | Cause.Done>, never, Env | Scope.Scope>
} = dual(
  (args) => isChannel(args[0]),
  Effect.fnUntraced(function*<OutElem, OutErr, OutDone, Env>(
    self: Channel<Arr.NonEmptyReadonlyArray<OutElem>, OutErr, OutDone, unknown, unknown, unknown, Env>,
    options: {
      readonly capacity: "unbounded"
    } | {
      readonly capacity: number
      readonly strategy?: "dropping" | "sliding" | "suspend" | undefined
    }
  ) {
    const scope = yield* Effect.scope
    const queue = yield* Queue.make<OutElem, OutErr | Cause.Done>({
      capacity: typeof options.capacity === "number" ? options.capacity : undefined,
      strategy: typeof options.capacity === "number" ? options.strategy : undefined
    })
    yield* Scope.addFinalizer(scope, Queue.shutdown(queue))
    yield* Effect.forkIn(runIntoQueueArray(self, queue), scope)
    return queue
  })
)
Referenced by 1 symbols