()
| 255 | } |
| 256 | |
| 257 | async function testShareConsumerBreak() { |
| 258 | // Verify that a consumer breaking mid-iteration detaches properly |
| 259 | const enc = new TextEncoder(); |
| 260 | async function* gen() { |
| 261 | yield [enc.encode('a')]; |
| 262 | yield [enc.encode('b')]; |
| 263 | yield [enc.encode('c')]; |
| 264 | } |
| 265 | const shared = share(gen(), { highWaterMark: 16 }); |
| 266 | const c1 = shared.pull(); |
| 267 | const c2 = shared.pull(); |
| 268 | |
| 269 | assert.strictEqual(shared.consumerCount, 2); |
| 270 | |
| 271 | // c1 breaks after first batch |
| 272 | // eslint-disable-next-line no-unused-vars |
| 273 | for await (const _ of c1) { |
| 274 | break; |
| 275 | } |
| 276 | // c1 should be detached |
| 277 | assert.strictEqual(shared.consumerCount, 1); |
| 278 | |
| 279 | // c2 should still get all data |
| 280 | const data2 = await text(c2); |
| 281 | assert.strictEqual(data2, 'abc'); |
| 282 | } |
| 283 | |
| 284 | async function testShareMultipleConsumersConcurrentPull() { |
| 285 | // Multiple consumers pulling concurrently should each receive all items |
no test coverage detected