Skip to content

Commit

Permalink
export entryCount to callback
Browse files Browse the repository at this point in the history
  • Loading branch information
faluelv committed Sep 6, 2016
1 parent f459dd9 commit 235dfdb
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions zip-node.js
Expand Up @@ -50,6 +50,7 @@ Unzip.prototype.getEntries = function(callback, onEnd) {
Unzip.prototype.getBuffer = function(whatYouNeed, options, callback) {
var finishedNumber = 0;
const output = {};
var entryCount = 0;

if (utils.isFunction(options)) {
callback = options;
Expand All @@ -64,7 +65,7 @@ Unzip.prototype.getBuffer = function(whatYouNeed, options, callback) {

this.getEntries(function(error, zipfile, entry, next) {
if (error) return callback(error);

entryCount = zipfile.entryCount;
var findIt = whatYouNeed.some(function(rule) {
if (utils.isThisWhatYouNeed(rule, entry.fileName)) {
Unzip.getEntryData(zipfile, entry, function(error, buffer) {
Expand All @@ -76,7 +77,7 @@ Unzip.prototype.getBuffer = function(whatYouNeed, options, callback) {
finishedNumber++;

if (finishedNumber >= whatYouNeed.length) {
callback(null, output);
callback(null, output, entryCount);
} else {
next();
}
Expand All @@ -89,7 +90,7 @@ Unzip.prototype.getBuffer = function(whatYouNeed, options, callback) {

}, function() {
if (finishedNumber < whatYouNeed.length) {
callback(null, output);
callback(null, output, entryCount);
}
});
};
Expand Down

0 comments on commit 235dfdb

Please sign in to comment.