Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions lib/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,19 +155,18 @@ Parse.prototype._readFile = function () {
var descriptorSig = new Buffer(4);
descriptorSig.writeUInt32LE(0x08074b50, 0);

var matchStream = new MatchStream({ pattern: descriptorSig }, function (buf, matched, extra) {
var matchStream = new MatchStream({ pattern: descriptorSig }, function (buf, matched) {
if (!matched) {
return hasEntryListener ? this.push(buf) : null;
}
self._pullStream.unpipe();
if (hasEntryListener) {
if (!matched) {
return this.push(buf);
}
this.push(buf);
}
setImmediate(function() {
self._pullStream.unpipe();
self._pullStream.prepend(extra);
self._processDataDescriptor(entry);
});
return this.push(null);
this.end();
}, function (extra) {
self._pullStream.prepend(extra);
self._processDataDescriptor(entry);
});

self._pullStream.pipe(matchStream);
Expand Down Expand Up @@ -240,7 +239,7 @@ Parse.prototype._readCentralDirectoryFileHeader = function () {
if (err) {
return self.emit('error', err);
}
return self._readRecord();
return setImmediate(self._readRecord.bind(self));
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"binary": "~0.3.0",
"readable-stream": "~1.0.0",
"setimmediate": "~1.0.1",
"match-stream": "0.0.1"
"match-stream": "git://github.com/EvanOxfeld/match-stream.git#callback-on-finish-wip"
},
"devDependencies": {
"tap": "~0.3.0",
Expand Down