| 58 | } |
| 59 | |
| 60 | async function testTapInPipeline() { |
| 61 | const { writer, readable } = push(); |
| 62 | const seen = []; |
| 63 | |
| 64 | const observer = tap(async (chunks) => { |
| 65 | if (chunks !== null) { |
| 66 | for (const chunk of chunks) { |
| 67 | seen.push(new TextDecoder().decode(chunk)); |
| 68 | } |
| 69 | } |
| 70 | }); |
| 71 | |
| 72 | writer.write('hello'); |
| 73 | writer.end(); |
| 74 | |
| 75 | // Use pull with tap as a transform |
| 76 | const result = pull(readable, observer); |
| 77 | const data = await text(result); |
| 78 | |
| 79 | assert.strictEqual(data, 'hello'); |
| 80 | assert.strictEqual(seen.length, 1); |
| 81 | assert.strictEqual(seen[0], 'hello'); |
| 82 | } |
| 83 | |
| 84 | // Tap callback error propagates through async pipeline |
| 85 | async function testTapAsyncErrorPropagation() { |