I'm currently using zlib node library (node version 14.19.1) using fs.createReadStream and then fs.createWriteStream. However I need a text file (all the .gz files contain exactly a single .csv text file) to continue working further downstream.
Here's the code I have so far (I'm using MeteorJS, hence the import statement instead of require):
import ZLib from 'zlib';
import fs from 'fs';
import stream from 'stream';
const gunzip = async function (fileInfo) {
    // unzip .gz file
    const source = fs.createReadStream(fileInfo.filePath);
    const destination = fs.createWriteStream(fileInfo.filePath.replace(".gz", ""));
    stream.pipeline(source, ZLib.createGunzip(), destination, (err) => {
        if (err) {
            console.error('An error occurred:', err);
            process.exitCode = 1;
        }
    });
};
I've tried several npm libraries that wrap around zlib (eg. 'node-gzip') however I get problems with them as they don't allow to set the optional windowBits value to 16 or beyond and hence I get an invalid header error - as found in many other SO posts).
Thanks in advance for your help!
