()
| 232 | } |
| 233 | |
| 234 | async function testShareLateJoiningConsumer() { |
| 235 | // A consumer that joins after some data has been consumed should only |
| 236 | // see data remaining in the buffer (not items already trimmed). |
| 237 | const enc = new TextEncoder(); |
| 238 | async function* gen() { |
| 239 | yield [enc.encode('a')]; |
| 240 | yield [enc.encode('b')]; |
| 241 | yield [enc.encode('c')]; |
| 242 | } |
| 243 | const shared = share(gen(), { highWaterMark: 16 }); |
| 244 | |
| 245 | // First consumer reads all data |
| 246 | const c1 = shared.pull(); |
| 247 | const data1 = await text(c1); |
| 248 | assert.strictEqual(data1, 'abc'); |
| 249 | |
| 250 | // Late-joining consumer: source is exhausted, buffer has been trimmed |
| 251 | // past all data by c1's reads, so c2 gets nothing. |
| 252 | const c2 = shared.pull(); |
| 253 | const data2 = await text(c2); |
| 254 | assert.strictEqual(data2, ''); |
| 255 | } |
| 256 | |
| 257 | async function testShareConsumerBreak() { |
| 258 | // Verify that a consumer breaking mid-iteration detaches properly |
no test coverage detected