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

Function peek

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

Source from the content-addressed store, hash-verified

1597 * @since 4.0.0
1598 */
1599export const peek = <A, E>(self: Dequeue<A, E>): Effect<A, E> =>
1600 internalEffect.suspend(() => {
1601 if (self.state._tag === "Done") {
1602 return self.state.exit
1603 }
1604 if (self.messages.length > 0 && self.messages.head) {
1605 return internalEffect.succeed(self.messages.head.array[self.messages.head.offset])
1606 }
1607 // Pending offers on a rendezvous queue are not visible to peek.
1608 return internalEffect.andThen(awaitTake(self, () => self.messages.length > 0), peek(self))
1609 })
1610
1611/**
1612 * Attempts to take one message from the queue synchronously.

Callers

nothing calls this directly

Calls 2

awaitTakeFunction · 0.85
succeedMethod · 0.45

Tested by

no test coverage detected