()
| 193 | |
| 194 | // Pull consumer break (return()) cleans up transform signal |
| 195 | async function testPullConsumerBreakCleanup() { |
| 196 | let signalAborted = false; |
| 197 | const trackingTransform = { |
| 198 | transform(source, options) { |
| 199 | options.signal.addEventListener('abort', () => { |
| 200 | signalAborted = true; |
| 201 | }); |
| 202 | return source; |
| 203 | }, |
| 204 | }; |
| 205 | async function* infiniteSource() { |
| 206 | let i = 0; |
| 207 | while (true) { |
| 208 | yield [new TextEncoder().encode(`chunk${i++}`)]; |
| 209 | } |
| 210 | } |
| 211 | // Consumer breaks after first chunk |
| 212 | // eslint-disable-next-line no-unused-vars |
| 213 | for await (const _ of pull(infiniteSource(), trackingTransform)) { |
| 214 | break; |
| 215 | } |
| 216 | // Give the abort handler a tick to fire |
| 217 | await new Promise(setImmediate); |
| 218 | assert.strictEqual(signalAborted, true); |
| 219 | } |
| 220 | |
| 221 | // Pull transform returning a Promise |
| 222 | async function testPullTransformReturnsPromise() { |
no test coverage detected