const { pipeline } = require('stream');
const fs = require('fs');
const transformStream = getTransformStream(); // Some transform stream
pipeline(
fs.createReadStream('source.txt'),
transformStream,
fs.createWriteStream('destination.txt'),
(err) => {
if (err) {
console.error('Pipeline failed.', err);
}
}
);
transformStream.destroy(); // ERR_STREAM_PREMATURE_CLOSE