()
| 6 | const { pipeTo, pipeToSync, from, fromSync } = require('stream/iter'); |
| 7 | |
| 8 | async function testPipeToSync() { |
| 9 | const written = []; |
| 10 | const writer = { |
| 11 | writeSync(chunk) { written.push(chunk); return true; }, |
| 12 | endSync() { return written.length; }, |
| 13 | fail() {}, |
| 14 | }; |
| 15 | |
| 16 | const totalBytes = pipeToSync(fromSync('pipe-data'), writer); |
| 17 | assert.strictEqual(totalBytes, 9); // 'pipe-data' = 9 UTF-8 bytes |
| 18 | assert.ok(written.length > 0); |
| 19 | const result = new TextDecoder().decode( |
| 20 | new Uint8Array(written.reduce((acc, c) => [...acc, ...c], []))); |
| 21 | assert.strictEqual(result, 'pipe-data'); |
| 22 | } |
| 23 | |
| 24 | async function testPipeTo() { |
| 25 | const written = []; |
no test coverage detected
searching dependent graphs…