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

Function peek

packages/effect/src/TxQueue.ts:1024–1038  ·  view source on GitHub ↗
(self: TxDequeue<A, E>)

Source from the content-addressed store, hash-verified

1022 * @since 2.0.0
1023 */
1024export const peek = <A, E>(self: TxDequeue<A, E>): Effect.Effect<A, E> =>
1025 Effect.gen(function*() {
1026 const state = yield* TxRef.get(self.stateRef)
1027 if (state._tag === "Done") {
1028 return yield* Effect.failCause(state.cause)
1029 }
1030
1031 const chunk = yield* TxChunk.get(self.items)
1032 const head = Chunk.head(chunk)
1033 if (Option.isNone(head)) {
1034 return yield* Effect.txRetry
1035 }
1036
1037 return head.value
1038 }).pipe(Effect.tx)
1039
1040/**
1041 * Gets the current size of the queue.

Callers

nothing calls this directly

Calls 2

pipeMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected