MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / lastX

Function lastX

source code/utils/generators.ts:5–14  ·  view source on GitHub ↗
(as: AsyncGenerator<A>)

Source from the content-addressed store, hash-verified

3const NO_VALUE = Symbol('NO_VALUE')
4
5export async function lastX<A>(as: AsyncGenerator<A>): Promise<A> {
6 let lastValue: A | typeof NO_VALUE = NO_VALUE
7 for await (const a of as) {
8 lastValue = a
9 }
10 if (lastValue === NO_VALUE) {
11 throw new Error('No items in generator')
12 }
13 return lastValue
14}
15
16export async function returnValue<A>(
17 as: AsyncGenerator<unknown, A>,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected