Node.js read a file in a zip without unzipping it
<p>I have a zip file (actually it's an epub file) I need to loop through the files in it and read them without unzipping them to the disk.</p>

<p>I tried to use a Node.js library called <code>JSZip</code> but the content of each file is stored in memory in Buffer and whenever I try to decode the buffer content to string the content returned is unreadable </p>

<p>Here's the code I tried:</p>

<pre><code>const zip = new JSZip();
  // read a zip file
    fs.readFile(epubFile, function (err, data) {
        if (err) throw err;
        zip.loadAsync(data).then(function (zip) {
            async.eachOf(zip.files, function (content, fileName, callback) {
                if (fileName.match(/json/)) {
                    var buf = content._data.compressedContent;
                    console.log(fileName);
                    console.log((new Buffer(buf)).toString('utf-8'));
                }
                callback();
            }, function (err) {
                if (err) {
                    console.log(err);
                }
            });
        });
    });
</code></pre>