(as: AsyncGenerator<A>)
| 3 | const NO_VALUE = Symbol('NO_VALUE') |
| 4 | |
| 5 | export 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 | |
| 16 | export async function returnValue<A>( |
| 17 | as: AsyncGenerator<unknown, A>, |
nothing calls this directly
no outgoing calls
no test coverage detected