<A = unknown, E = unknown>(u: unknown): u is Queue<A, E>Type guard to check if a value is a Queue.
When to use
Use to narrow an unknown value to a full Queue before passing it to APIs
that need both offering and taking capabilities.
Source effect/Queue.ts:453 lines
export const const isQueue: <A = unknown, E = unknown>(
u: unknown
) => u is Queue<A, E>
Type guard to check if a value is a Queue.
When to use
Use to narrow an unknown value to a full Queue before passing it to APIs
that need both offering and taking capabilities.
isQueue = <function (type parameter) A in <A = unknown, E = unknown>(u: unknown): u is Queue<A, E>A = unknown, function (type parameter) E in <A = unknown, E = unknown>(u: unknown): u is Queue<A, E>E = unknown>(
u: unknownu: unknown
): u: unknownu is interface Queue<in out A, in out E = never>A Queue is an asynchronous queue that can be offered to and taken from.
Details
It also supports signaling that it is done or failed.
Example (Offering and taking queue values)
import { Effect, Queue } from "effect"
const program = Effect.gen(function*() {
// Create a bounded queue
const queue = yield* Queue.bounded<string>(10)
// Producer: offer items to the queue
yield* Queue.offer(queue, "hello")
yield* Queue.offerAll(queue, ["world", "!"])
// Consumer: take items from the queue
const item1 = yield* Queue.take(queue)
const item2 = yield* Queue.take(queue)
const item3 = yield* Queue.take(queue)
console.log([item1, item2, item3]) // ["hello", "world", "!"]
})
Companion namespace containing type-level metadata and low-level state types
for Queue.
Queue<function (type parameter) A in <A = unknown, E = unknown>(u: unknown): u is Queue<A, E>A, function (type parameter) E in <A = unknown, E = unknown>(u: unknown): u is Queue<A, E>E> => import hasPropertyhasProperty(u: unknownu, const TypeId: "~effect/Queue"TypeId)