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

Function peek

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

Source from the content-addressed store, hash-verified

1496 * @since 4.0.0
1497 */
1498export const peek = <A, E>(self: Dequeue<A, E>): Effect<A, E> =>
1499 internalEffect.suspend(() => {
1500 if (self.state._tag === "Done") {
1501 return self.state.exit
1502 }
1503 if (self.messages.length > 0 && self.messages.head) {
1504 return internalEffect.succeed(self.messages.head.array[self.messages.head.offset])
1505 }
1506 return internalEffect.andThen(awaitTake(self), peek(self))
1507 })
1508
1509/**
1510 * 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