Reputation: 1
I am using packages "tar-stream" and "zlib" to extract files from a TGZ file.
Is there a way to send data to a custom Transform function ?
"tarStream.extract()" doesn't have a ".pipe()" callback so i can't build my own data and send it to the next pipe.
Thanks
My code down below:
fs.createReadStream("/path/to/my/tgz/file")
.pipe(zlib.createGunzip())
.pipe(extract)
// .pipe(myCustomTransformer); <---- this doesn't work, getting an error
extract.on("entry", (header, stream, next) => {
let chunks = '';
stream.on("end", async function() {
/*
* Try to pipe some data to a custom transform function ...
* Example: ().pipe(myCustomTransformer, { chunks })
*/
next();
});
stream.on("data", chunk => chunks += chunk.toString("utf-8"));
});
Upvotes: 0
Views: 37