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

Function poll

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

Source from the content-addressed store, hash-verified

1457 * @since 2.0.0
1458 */
1459export const poll = <A, E>(self: Dequeue<A, E>): Effect<Option.Option<A>> =>
1460 internalEffect.suspend(() => {
1461 const result = takeUnsafe(self)
1462 if (result === undefined) {
1463 return internalEffect.succeed(Option.none())
1464 }
1465 if (result._tag === "Success") {
1466 return internalEffect.succeed(Option.some(result.value))
1467 }
1468 return internalEffect.succeed(Option.none())
1469 })
1470
1471/**
1472 * 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