()
| 184 | // ============================================================================= |
| 185 | |
| 186 | async function testDropNewestDiscards() { |
| 187 | const chunks = []; |
| 188 | const writable = new Writable({ |
| 189 | highWaterMark: 5, |
| 190 | write(chunk, enc, cb) { |
| 191 | chunks.push(Buffer.from(chunk)); |
| 192 | // Never call cb -- data stays buffered |
| 193 | }, |
| 194 | }); |
| 195 | |
| 196 | const writer = fromWritable(writable, { backpressure: 'drop-newest' }); |
| 197 | |
| 198 | // First write fills the buffer |
| 199 | await writer.write('12345'); |
| 200 | |
| 201 | // Second write should be silently discarded (no reject, no block) |
| 202 | await writer.write('dropped'); |
| 203 | |
| 204 | // Only the first chunk was actually written to the writable |
| 205 | assert.strictEqual(chunks.length, 1); |
| 206 | assert.strictEqual(chunks[0].toString(), '12345'); |
| 207 | } |
| 208 | |
| 209 | // ============================================================================= |
| 210 | // drop-newest: writev discards entire batch when full |
no test coverage detected