<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.
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> => hasProperty<"~effect/Queue">(self: unknown, property: "~effect/Queue"): self is { [K in "~effect/Queue"]: unknown; } (+1 overload)Checks whether a value has a given property key.
When to use
Use when you need a Predicate guard for property access on unknown
values with a simple structural object check.
Details
Uses the in operator and isObjectKeyword. This does not check property
value types.
Example (Guarding object properties)
import { Predicate } from "effect"
const hasName = Predicate.hasProperty("name")
const data: unknown = { name: "Ada" }
if (hasName(data)) {
console.log(data.name)
}
hasProperty(u: unknownu, const TypeId: "~effect/Queue"TypeId)