effect-io-ai

Package: effect
Module: TxPriorityQueue

TxPriorityQueue.peekOption

Observes the smallest element without removing it, returning None when the queue is empty.

When to use

Use to inspect the next prioritized value without retrying on an empty queue.

Example (Peeking without retrying)

import { Effect, Option, Order, TxPriorityQueue } from "effect"

const program = Effect.gen(function*() {
  const pq = yield* TxPriorityQueue.empty<number>(Order.Number)
  const result = yield* TxPriorityQueue.peekOption(pq)
  console.log(Option.isNone(result)) // true
})

Signature

declare const peekOption: <A>(self: TxPriorityQueue<A>) => Effect.Effect<Option<A>>

Source

Since v2.0.0