| 1022 | * @since 2.0.0 |
| 1023 | */ |
| 1024 | export 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. |