MCPcopy Create free account
hub / github.com/Effect-TS/effect / poll

Function poll

packages/effect/src/Queue.ts:1559–1569  ·  view source on GitHub ↗
(self: Dequeue<A, E>)

Source from the content-addressed store, hash-verified

1557 * @since 2.0.0
1558 */
1559export const poll = <A, E>(self: Dequeue<A, E>): Effect<Option.Option<A>> =>
1560 suspendTake(() => {
1561 const result = takeUnsafe(self)
1562 if (result === undefined) {
1563 return internalEffect.succeed(Option.none())
1564 }
1565 if (result._tag === "Success") {
1566 return internalEffect.succeed(Option.some(result.value))
1567 }
1568 return internalEffect.succeed(Option.none())
1569 })
1570
1571/**
1572 * Peeks at the next item without removing it.

Callers

nothing calls this directly

Calls 3

takeUnsafeFunction · 0.85
someMethod · 0.80
succeedMethod · 0.45

Tested by

no test coverage detected