<A = unknown, E = unknown>(u: unknown): u is Dequeue<A, E>Type guard to check if a value is a Dequeue.
When to use
Use to narrow an unknown value before passing it to read-side queue operations.
export const const isDequeue: <
A = unknown,
E = unknown
>(
u: unknown
) => u is Dequeue<A, E>
Type guard to check if a value is a Dequeue.
When to use
Use to narrow an unknown value before passing it to read-side queue
operations.
isDequeue = <function (type parameter) A in <A = unknown, E = unknown>(u: unknown): u is Dequeue<A, E>A = unknown, function (type parameter) E in <A = unknown, E = unknown>(u: unknown): u is Dequeue<A, E>E = unknown>(
u: unknownu: unknown
): u: unknownu is interface Dequeue<out A, out E = never>A Dequeue is a queue that can be taken from.
Details
This interface represents the read-only part of a Queue, allowing you to take
elements from the queue but not offer elements to it.
Example (Taking through dequeue handles)
import { Effect, Queue } from "effect"
const program = Effect.gen(function*() {
const queue = yield* Queue.bounded<string, never>(10)
// A Dequeue can only take elements
const dequeue: Queue.Dequeue<string> = queue
// Pre-populate the queue
yield* Queue.offerAll(queue, ["a", "b", "c"])
// Take elements using dequeue interface
const item = yield* Queue.take(dequeue)
console.log(item) // "a"
})
Companion namespace containing type-level metadata for the Dequeue
read-only queue interface.
Dequeue<function (type parameter) A in <A = unknown, E = unknown>(u: unknown): u is Dequeue<A, E>A, function (type parameter) E in <A = unknown, E = unknown>(u: unknown): u is Dequeue<A, E>E> => hasProperty<"~effect/Queue/Dequeue">(self: unknown, property: "~effect/Queue/Dequeue"): self is { [K in "~effect/Queue/Dequeue"]: 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 DequeueTypeId: "~effect/Queue/Dequeue"DequeueTypeId)