lib/zip.js
function Zip(output) {
  this.output = output;
  // Set to true when zip is closed
  this._closed = false;
  // Keep track of all files added so we can write central directory
  this._files = [];
  // The currently active file
  this._active = null;
  // Current offset in the output stream
  this._offset = 0;

  var zip = this;
  output.on("error", function(error) {
    debug("Zip file encountered an error", error);
    // Closed output, propagate.
    // Output error, destroy all files and propagate.
    zip._closed = true;
    for (var i in zip._files) {
      var file = zip._files[i];
      if (!file._done)
        file.destroy();
    }
    zip.emit("error", error);
  });
  output.on("finish", function () {
    debug("Zip completed");
    zip.emit("end");
  })
  output.on("close", function() {
    debug("Zip completed");
    zip.emit("end");
  });
}
function Zip(output) {
  this.output = output;
  // Set to true when zip is closed
  this._closed = false;
  // Keep track of all files added so we can write central directory
  this._files = [];
  // The currently active file
  this._active = null;
  // Current offset in the output stream
  this._offset = 0;

  var zip = this;
  output.on("error", function(error) {
    debug("Zip file encountered an error", error);
    // Closed output, propagate.
    // Output error, destroy all files and propagate.
    zip._closed = true;
    for (var i in zip._files) {
      var file = zip._files[i];
      if (!file._done)
        file.destroy();
    }
    zip.emit("error", error);
  });
  output.on("finish", function () {
    debug("Zip completed");
    zip.emit("end");
  })
  output.on("close", function() {
    debug("Zip completed");
    zip.emit("end");
  });
}
Creates a new zip.  output - Output stream  Emits the following events: end   - Finished writing to output stream error - Encountered an error writing to output stream