(originalStream, onData)
| 32 | } |
| 33 | |
| 34 | function tapStream(originalStream, onData) { |
| 35 | const tee = new PassThrough(); |
| 36 | originalStream.pipe(tee); |
| 37 | |
| 38 | let data = ''; |
| 39 | tee.on('data', (chunk) => { |
| 40 | data += chunk; |
| 41 | }); |
| 42 | tee.on('end', () => { |
| 43 | onData(data); |
| 44 | }); |
| 45 | |
| 46 | return tee; // Use this stream for downstream consumers |
| 47 | } |
| 48 | |
| 49 | export { readFromStream, tapStream, readStream }; |
| 50 | export default { |
no outgoing calls
no test coverage detected