diff --git a/lib/parse.js b/lib/parse.js index e9930c5..a0d0474 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -109,9 +109,6 @@ Parse.prototype._readFile = function () { } var hasEntryListener = self._hasEntryListener; - if (hasEntryListener) { - self.emit('entry', entry); - } self._pullStream.pull(vars.extraFieldLength, function (err, extraField) { if (err) { @@ -142,6 +139,7 @@ Parse.prototype._readFile = function () { entry.size = vars.uncompressedSize; if (hasEntryListener) { entry.on('finish', self._readRecord.bind(self)); + self.emit('entry', entry); self._pullStream.pipe(vars.compressedSize, inflater).pipe(entry); } else { self._pullStream.drain(vars.compressedSize, function (err) { @@ -166,6 +164,7 @@ Parse.prototype._readFile = function () { self._pullStream.unpipe(); self._pullStream.prepend(extra); self._processDataDescriptor(entry); + }); return this.push(null); }); @@ -196,6 +195,8 @@ Parse.prototype._processDataDescriptor = function (entry) { .vars; entry.size = vars.uncompressedSize; + if (self._hasEntryListener) + self.emit('entry', entry); self._readRecord(); }); };