(next: AsyncIteratorClassNextFn<T, TReturn>, cleanup: AsyncIteratorClassCleanupFn)
| 29 | #next: AsyncIteratorClassNextFn<T, TReturn> |
| 30 | |
| 31 | constructor(next: AsyncIteratorClassNextFn<T, TReturn>, cleanup: AsyncIteratorClassCleanupFn) { |
| 32 | this.#cleanup = cleanup |
| 33 | this.#next = sequential(async () => { |
| 34 | if (this.#isDone) { |
| 35 | return { done: true, value: undefined as any } |
| 36 | } |
| 37 | |
| 38 | try { |
| 39 | const result = await next() |
| 40 | |
| 41 | if (result.done) { |
| 42 | this.#isDone = true |
| 43 | } |
| 44 | |
| 45 | return result |
| 46 | } |
| 47 | catch (err) { |
| 48 | this.#isDone = true |
| 49 | throw err |
| 50 | } |
| 51 | finally { |
| 52 | if (this.#isDone && !this.#isExecuteComplete) { |
| 53 | this.#isExecuteComplete = true |
| 54 | await this.#cleanup('next') |
| 55 | } |
| 56 | } |
| 57 | }) |
| 58 | } |
| 59 | |
| 60 | next(): Promise<IteratorResult<T, TReturn>> { |
| 61 | return this.#next() |
nothing calls this directly
no test coverage detected