code:
var fs = require("fs");
var zlib = require("zlib");
var fd_slicer = require("fd-slicer2");
var crc32 = require("buffer-crc32");
var util = require("util");
var EventEmitter = require("events").EventEmitter;
var Transform = require("stream").Transform;
var PassThrough = require("stream").PassThrough;
var Writable = require("stream").Writable;

exports.open = open;
exports.fromFd = fromFd;
exports.fromBuffer = fromBuffer;
exports.fromRandomAccessReader = fromRandomAccessReader;
exports.dosDateTimeToDate = dosDateTimeToDate;
exports.validateFileName = validateFileName;
exports.ZipFile = ZipFile;
exports.Entry = Entry;
exports.RandomAccessReader = RandomAccessReader;

function open(path, options, callback) {
  if (typeof options === "function") {
    callback = options;
    options = null;
  }
  if (options == null) options = {};
  if (options.autoClose == null) options.autoClose = true;
  if (options.lazyEntries == null) options.lazyEntries = false;
  if (options.decodeStrings == null) options.decodeStrings = true;
  if (options.validateEntrySizes == null) options.validateEntrySizes = true;
  if (options.strictFileNames == null) options.strictFileNames = false;
  if (callback == null) callback = defaultCallback;
  fs.open(path, "r", function(err, fd) {
    if (err) return callback(err);
    fromFd(fd, options, function(err, zipfile) {
      if (err) fs.close(fd, defaultCallback);
      callback(err, zipfile);
    });
  });
}

function fromFd(fd, options, callback) {
  if (typeof options === "function") {
    callback = options;
    options = null;
  }
  if (options == null) options = {};
  if (options.autoClose == null) options.autoClose = false;
  if (options.lazyEntries == null) options.lazyEntries = false;
  if (options.decodeStrings == null) options.decodeStrings = true;
  if (options.validateEntrySizes == null) options.validateEntrySizes = true;
  if (options.strictFileNames == null) options.strictFileNames = false;
  if (callback == null) callback = defaultCallback;
  fs.fstat(fd, function(err, stats) {
    if (err) return callback(err);
    var reader = fd_slicer.createFromFd(fd, {autoClose: true});
    fromRandomAccessReader(reader, stats.size, options, callback);
  });
}

function fromBuffer(buffer, options, callback) {
  if (typeof options === "function") {
    callback = options;
    options = null;
  }
  if (options == null) options = {};
  options.autoClose = false;
  if (options.lazyEntries == null) options.lazyEntries = false;
  if (options.decodeStrings == null) options.decodeStrings = true;
  if (options.validateEntrySizes == null) options.validateEntrySizes = true;
  if (options.strictFileNames == null) options.strictFileNames = false;
  // limit the max chunk size. see https://github.com/thejoshwolfe/yauzl/issues/87
  var reader = fd_slicer.createFromBuffer(buffer, {maxChunkSize: 0x10000});
  fromRandomAccessReader(reader, buffer.length, options, callback);
}

function fromRandomAccessReader(reader, totalSize, options, callback) {
  if (typeof options === "function") {
    callback = options;
    options = null;
  }
  if (options == null) options = {};
  if (options.autoClose == null) options.autoClose = true;
  if (options.lazyEntries == null) options.lazyEntries = false;
  if (options.decodeStrings == null) options.decodeStrings = true;
  var decodeStrings = !!options.decodeStrings;
  if (options.validateEntrySizes == null) options.validateEntrySizes = true;
  if (options.strictFileNames == null) options.strictFileNames = false;
  if (callback == null) callback = defaultCallback;
  if (typeof totalSize !== "number") throw new Error("expected totalSize parameter to be a number");
  if (totalSize > Number.MAX_SAFE_INTEGER) {
    throw new Error("zip file too large. only file sizes up to 2^52 are supported due to JavaScript's Number type being an IEEE 754 double.");
  }

  // the matching unref() call is in zipfile.close()
  reader.ref();

  // eocdr means End of Central Directory Record.
  // search backwards for the eocdr signature.
  // the last field of the eocdr is a variable-length comment.
  // the comment size is encoded in a 2-byte field in the eocdr, which we can't find without trudging backwards through the comment to find it.
  // as a consequence of this design decision, it's possible to have ambiguous zip file metadata if a coherent eocdr was in the comment.
  // we search backwards for a eocdr signature, and hope that whoever made the zip file was smart enough to forbid the eocdr signature in the comment.
  var eocdrWithoutCommentSize = 22;
  var maxCommentSize = 0xffff; // 2-byte size
  var bufferSize = Math.min(eocdrWithoutCommentSize + maxCommentSize, totalSize);
  var buffer = newBuffer(bufferSize);
  var bufferReadStart = totalSize - buffer.length;
  readAndAssertNoEof(reader, buffer, 0, bufferSize, bufferReadStart, function(err) {
    if (err) return callback(err);
    for (var i = bufferSize - eocdrWithoutCommentSize; i >= 0; i -= 1) {
      if (buffer.readUInt32LE(i) !== 0x06054b50) continue;
      // found eocdr
      var eocdrBuffer = buffer.slice(i);

      // 0 - End of central directory signature = 0x06054b50
      // 4 - Number of this disk
      var diskNumber = eocdrBuffer.readUInt16LE(4);
      if (diskNumber !== 0) {
        return callback(new Error("multi-disk zip files are not supported: found disk number: " + diskNumber));
      }
      // 6 - Disk where central directory starts
      // 8 - Number of central directory records on this disk
      // 10 - Total number of central directory records
      var entryCount = eocdrBuffer.readUInt16LE(10);
      // 12 - Size of central directory (bytes)
      // 16 - Offset of start of central directory, relative to start of archive
      var centralDirectoryOffset = eocdrBuffer.readUInt32LE(16);
      // 20 - Comment length
      var commentLength = eocdrBuffer.readUInt16LE(20);
      var expectedCommentLength = eocdrBuffer.length - eocdrWithoutCommentSize;
      if (commentLength !== expectedCommentLength) {
        return callback(new Error("invalid comment length. expected: " + expectedCommentLength + ". found: " + commentLength));
      }
      // 22 - Comment
      // the encoding is always cp437.
      var comment = decodeStrings ? decodeBuffer(eocdrBuffer, 22, eocdrBuffer.length, false)
                                  : eocdrBuffer.slice(22);

      if (!(entryCount === 0xffff || centralDirectoryOffset === 0xffffffff)) {
        return callback(null, new ZipFile(reader, centralDirectoryOffset, totalSize, entryCount, comment, options.autoClose, options.lazyEntries, decodeStrings, options.validateEntrySizes, options.strictFileNames));
      }

      // ZIP64 format

      // ZIP64 Zip64 end of central directory locator
      var zip64EocdlBuffer = newBuffer(20);
      var zip64EocdlOffset = bufferReadStart + i - zip64EocdlBuffer.length;
      readAndAssertNoEof(reader, zip64EocdlBuffer, 0, zip64EocdlBuffer.length, zip64EocdlOffset, function(err) {
        if (err) return callback(err);

        // 0 - zip64 end of central dir locator signature = 0x07064b50
        if (zip64EocdlBuffer.readUInt32LE(0) !== 0x07064b50) {
          return callback(new Error("invalid zip64 end of central directory locator signature"));
        }
        // 4 - number of the disk with the start of the zip64 end of central directory
        // 8 - relative offset of the zip64 end of central directory record
        var zip64EocdrOffset = readUInt64LE(zip64EocdlBuffer, 8);
        // 16 - total number of disks

        // ZIP64 end of central directory record
        var zip64EocdrBuffer = newBuffer(56);
        readAndAssertNoEof(reader, zip64EocdrBuffer, 0, zip64EocdrBuffer.length, zip64EocdrOffset, function(err) {
          if (err) return callback(err);

          // 0 - zip64 end of central dir signature                           4 bytes  (0x06064b50)
          if (zip64EocdrBuffer.readUInt32LE(0) !== 0x06064b50) {
            return callback(new Error("invalid zip64 end of central directory record signature"));
          }
          // 4 - size of zip64 end of central directory record                8 bytes
          // 12 - version made by                                             2 bytes
          // 14 - version needed to extract                                   2 bytes
          // 16 - number of this disk                                         4 bytes
          // 20 - number of the disk with the start of the central directory  4 bytes
          // 24 - total number of entries in the central directory on this disk         8 bytes
          // 32 - total number of entries in the central directory            8 bytes
          entryCount = readUInt64LE(zip64EocdrBuffer, 32);
          // 40 - size of the central directory                               8 bytes
          // 48 - offset of start of central directory with respect to the starting disk number     8 bytes
          centralDirectoryOffset = readUInt64LE(zip64EocdrBuffer, 48);
          // 56 - zip64 extensible data sector                                (variable size)
          return callback(null, new ZipFile(reader, centralDirectoryOffset, totalSize, entryCount, comment, options.autoClose, options.lazyEntries, decodeStrings, options.validateEntrySizes, options.strictFileNames));
        });
      });
      return;
    }
    callback(new Error("end of central directory record signature not found"));
  });
}

util.inherits(ZipFile, EventEmitter);
function ZipFile(reader, centralDirectoryOffset, fileSize, entryCount, comment, autoClose, lazyEntries, decodeStrings, validateEntrySizes, strictFileNames) {
  var self = this;
  EventEmitter.call(self);
  self.reader = reader;
  // forward close events
  self.reader.on("error", function(err) {
    // error closing the fd
    emitError(self, err);
  });
  self.reader.once("close", function() {
    self.emit("close");
  });
  self.readEntryCursor = centralDirectoryOffset;
  self.fileSize = fileSize;
  self.entryCount = entryCount;
  self.comment = comment;
  self.entriesRead = 0;
  self.autoClose = !!autoClose;
  self.lazyEntries = !!lazyEntries;
  self.decodeStrings = !!decodeStrings;
  self.validateEntrySizes = !!validateEntrySizes;
  self.strictFileNames = !!strictFileNames;
  self.isOpen = true;
  self.emittedError = false;

  if (!self.lazyEntries) self._readEntry();
}
ZipFile.prototype.close = function() {
  if (!this.isOpen) return;
  this.isOpen = false;
  this.reader.unref();
};

function emitErrorAndAutoClose(self, err) {
  if (self.autoClose) self.close();
  emitError(self, err);
}
function emitError(self, err) {
  if (self.emittedError) return;
  self.emittedError = true;
  self.emit("error", err);
}

ZipFile.prototype.readEntry = function() {
  if (!this.lazyEntries) throw new Error("readEntry() called without lazyEntries:true");
  this._readEntry();
};
ZipFile.prototype._readEntry = function() {
  var self = this;
  if (self.entryCount === self.entriesRead) {
    // done with metadata
    setImmediate(function() {
      if (self.autoClose) self.close();
      if (self.emittedError) return;
      self.emit("end");
    });
    return;
  }
  if (self.emittedError) return;
  var buffer = newBuffer(46);
  readAndAssertNoEof(self.reader, buffer, 0, buffer.length, self.readEntryCursor, function(err) {
    if (err) return emitErrorAndAutoClose(self, err);
    if (self.emittedError) return;
    var entry = new Entry();
    // 0 - Central directory file header signature
    var signature = buffer.readUInt32LE(0);
    if (signature !== 0x02014b50) return emitErrorAndAutoClose(self, new Error("invalid central directory file header signature: 0x" + signature.toString(16)));
    // 4 - Version made by
    entry.versionMadeBy = buffer.readUInt16LE(4);
    // 6 - Version needed to extract (minimum)
    entry.versionNeededToExtract = buffer.readUInt16LE(6);
    // 8 - General purpose bit flag
    entry.generalPurposeBitFlag = buffer.readUInt16LE(8);
    // 10 - Compression method
    entry.compressionMethod = buffer.readUInt16LE(10);
    // 12 - File last modification time
    entry.lastModFileTime = buffer.readUInt16LE(12);
    // 14 - File last modification date
    entry.lastModFileDate = buffer.readUInt16LE(14);
    // 16 - CRC-32
    entry.crc32 = buffer.readUInt32LE(16);
    // 20 - Compressed size
    entry.compressedSize = buffer.readUInt32LE(20);
    // 24 - Uncompressed size
    entry.uncompressedSize = buffer.readUInt32LE(24);
    // 28 - File name length (n)
    entry.fileNameLength = buffer.readUInt16LE(28);
    // 30 - Extra field length (m)
    entry.extraFieldLength = buffer.readUInt16LE(30);
    // 32 - File comment length (k)
    entry.fileCommentLength = buffer.readUInt16LE(32);
    // 34 - Disk number where file starts
    // 36 - Internal file attributes
    entry.internalFileAttributes = buffer.readUInt16LE(36);
    // 38 - External file attributes
    entry.externalFileAttributes = buffer.readUInt32LE(38);
    // 42 - Relative offset of local file header
    entry.relativeOffsetOfLocalHeader = buffer.readUInt32LE(42);

    if (entry.generalPurposeBitFlag & 0x40) return emitErrorAndAutoClose(self, new Error("strong encryption is not supported"));

    self.readEntryCursor += 46;

    buffer = newBuffer(entry.fileNameLength + entry.extraFieldLength + entry.fileCommentLength);
    readAndAssertNoEof(self.reader, buffer, 0, buffer.length, self.readEntryCursor, function(err) {
      if (err) return emitErrorAndAutoClose(self, err);
      if (self.emittedError) return;
      // 46 - File name
      var isUtf8 = (entry.generalPurposeBitFlag & 0x800) !== 0;
      entry.fileName = self.decodeStrings ? decodeBuffer(buffer, 0, entry.fileNameLength, isUtf8)
                                          : buffer.slice(0, entry.fileNameLength);

      // 46+n - Extra field
      var fileCommentStart = entry.fileNameLength + entry.extraFieldLength;
      var extraFieldBuffer = buffer.slice(entry.fileNameLength, fileCommentStart);
      entry.extraFields = [];
      var i = 0;
      while (i < extraFieldBuffer.length - 3) {
        var headerId = extraFieldBuffer.readUInt16LE(i + 0);
        var dataSize = extraFieldBuffer.readUInt16LE(i + 2);
        var dataStart = i + 4;
        var dataEnd = dataStart + dataSize;
        if (dataEnd > extraFieldBuffer.length) return emitErrorAndAutoClose(self, new Error("extra field length exceeds extra field buffer size"));
        var dataBuffer = newBuffer(dataSize);
        extraFieldBuffer.copy(dataBuffer, 0, dataStart, dataEnd);
        entry.extraFields.push({
          id: headerId,
          data: dataBuffer,
        });
        i = dataEnd;
      }

      // 46+n+m - File comment
      entry.fileComment = self.decodeStrings ? decodeBuffer(buffer, fileCommentStart, fileCommentStart + entry.fileCommentLength, isUtf8)
                                             : buffer.slice(fileCommentStart, fileCommentStart + entry.fileCommentLength);
      // compatibility hack for https://github.com/thejoshwolfe/yauzl/issues/47
      entry.comment = entry.fileComment;

      self.readEntryCursor += buffer.length;
      self.entriesRead += 1;

      if (entry.uncompressedSize            === 0xffffffff ||
          entry.compressedSize              === 0xffffffff ||
          entry.relativeOffsetOfLocalHeader === 0xffffffff) {
        // ZIP64 format
        // find the Zip64 Extended Information Extra Field
        var zip64EiefBuffer = null;
        for (var i = 0; i < entry.extraFields.length; i++) {
          var extraField = entry.extraFields[i];
          if (extraField.id === 0x0001) {
            zip64EiefBuffer = extraField.data;
            break;
          }
        }
        if (zip64EiefBuffer == null) {
          return emitErrorAndAutoClose(self, new Error("expected zip64 extended information extra field"));
        }
        var index = 0;
        // 0 - Original Size          8 bytes
        if (entry.uncompressedSize === 0xffffffff) {
          if (index + 8 > zip64EiefBuffer.length) {
            return emitErrorAndAutoClose(self, new Error("zip64 extended information extra field does not include uncompressed size"));
          }
          entry.uncompressedSize = readUInt64LE(zip64EiefBuffer, index);
          index += 8;
        }
        // 8 - Compressed Size        8 bytes
        if (entry.compressedSize === 0xffffffff) {
          if (index + 8 > zip64EiefBuffer.length) {
            return emitErrorAndAutoClose(self, new Error("zip64 extended information extra field does not include compressed size"));
          }
          entry.compressedSize = readUInt64LE(zip64EiefBuffer, index);
          index += 8;
        }
        // 16 - Relative Header Offset 8 bytes
        if (entry.relativeOffsetOfLocalHeader === 0xffffffff) {
          if (index + 8 > zip64EiefBuffer.length) {
            return emitErrorAndAutoClose(self, new Error("zip64 extended information extra field does not include relative header offset"));
          }
          entry.relativeOffsetOfLocalHeader = readUInt64LE(zip64EiefBuffer, index);
          index += 8;
        }
        // 24 - Disk Start Number      4 bytes
      }

      // check for Info-ZIP Unicode Path Extra Field (0x7075)
      // see https://github.com/thejoshwolfe/yauzl/issues/33
      if (self.decodeStrings) {
        for (var i = 0; i < entry.extraFields.length; i++) {
          var extraField = entry.extraFields[i];
          if (extraField.id === 0x7075) {
            if (extraField.data.length < 6) {
              // too short to be meaningful
              continue;
            }
            // Version       1 byte      version of this extra field, currently 1
            if (extraField.data.readUInt8(0) !== 1) {
              // > Changes may not be backward compatible so this extra
              // > field should not be used if the version is not recognized.
              continue;
            }
            // NameCRC32     4 bytes     File Name Field CRC32 Checksum
            var oldNameCrc32 = extraField.data.readUInt32LE(1);
            if (crc32.unsigned(buffer.slice(0, entry.fileNameLength)) !== oldNameCrc32) {
              // > If the CRC check fails, this UTF-8 Path Extra Field should be
              // > ignored and the File Name field in the header should be used instead.
              continue;
            }
            // UnicodeName   Variable    UTF-8 version of the entry File Name
            entry.fileName = decodeBuffer(extraField.data, 5, extraField.data.length, true);
            break;
          }
        }
      }

      // validate file size
      if (self.validateEntrySizes && entry.compressionMethod === 0) {
        var expectedCompressedSize = entry.uncompressedSize;
        if (entry.isEncrypted()) {
          // traditional encryption prefixes the file data with a header
          expectedCompressedSize += 12;
        }
        if (entry.compressedSize !== expectedCompressedSize) {
          var msg = "compressed/uncompressed size mismatch for stored file: " + entry.compressedSize + " != " + entry.uncompressedSize;
          return emitErrorAndAutoClose(self, new Error(msg));
        }
      }

      if (self.decodeStrings) {
        if (!self.strictFileNames) {
          // allow backslash
          entry.fileName = entry.fileName.replace(/\\/g, "/");
        }
        var errorMessage = validateFileName(entry.fileName, self.validateFileNameOptions);
        if (errorMessage != null) return emitErrorAndAutoClose(self, new Error(errorMessage));
      }
      self.emit("entry", entry);

      if (!self.lazyEntries) self._readEntry();
    });
  });
};

ZipFile.prototype.openReadStream = function(entry, options, callback) {
  var self = this;
  // parameter validation
  var relativeStart = 0;
  var relativeEnd = entry.compressedSize;
  if (callback == null) {
    callback = options;
    options = {};
  } else {
    // validate options that the caller has no excuse to get wrong
    if (options.decrypt != null) {
      if (!entry.isEncrypted()) {
        throw new Error("options.decrypt can only be specified for encrypted entries");
      }
      if (options.decrypt !== false) throw new Error("invalid options.decrypt value: " + options.decrypt);
      if (entry.isCompressed()) {
        if (options.decompress !== false) throw new Error("entry is encrypted and compressed, and options.decompress !== false");
      }
    }
    if (options.decompress != null) {
      if (!entry.isCompressed()) {
        throw new Error("options.decompress can only be specified for compressed entries");
      }
      if (!(options.decompress === false || options.decompress === true)) {
        throw new Error("invalid options.decompress value: " + options.decompress);
      }
    }
    if (options.start != null || options.end != null) {
      if (entry.isCompressed() && options.decompress !== false) {
        throw new Error("start/end range not allowed for compressed entry without options.decompress === false");
      }
      if (entry.isEncrypted() && options.decrypt !== false) {
        throw new Error("start/end range not allowed for encrypted entry without options.decrypt === false");
      }
    }
    if (options.start != null) {
      relativeStart = options.start;
      if (relativeStart < 0) throw new Error("options.start < 0");
      if (relativeStart > entry.compressedSize) throw new Error("options.start > entry.compressedSize");
    }
    if (options.end != null) {
      relativeEnd = options.end;
      if (relativeEnd < 0) throw new Error("options.end < 0");
      if (relativeEnd > entry.compressedSize) throw new Error("options.end > entry.compressedSize");
      if (relativeEnd < relativeStart) throw new Error("options.end < options.start");
    }
  }
  // any further errors can either be caused by the zipfile,
  // or were introduced in a minor version of yauzl,
  // so should be passed to the client rather than thrown.
  if (!self.isOpen) return callback(new Error("closed"));
  if (entry.isEncrypted()) {
    if (options.decrypt !== false) return callback(new Error("entry is encrypted, and options.decrypt !== false"));
  }
  // make sure we don't lose the fd before we open the actual read stream
  self.reader.ref();
  var buffer = newBuffer(30);
  readAndAssertNoEof(self.reader, buffer, 0, buffer.length, entry.relativeOffsetOfLocalHeader, function(err) {
    try {
      if (err) return callback(err);
      // 0 - Local file header signature = 0x04034b50
      var signature = buffer.readUInt32LE(0);
      if (signature !== 0x04034b50) {
        return callback(new Error("invalid local file header signature: 0x" + signature.toString(16)));
      }
      // all this should be redundant
      // 4 - Version needed to extract (minimum)
      // 6 - General purpose bit flag
      // 8 - Compression method
      // 10 - File last modification time
      // 12 - File last modification date
      // 14 - CRC-32
      // 18 - Compressed size
      // 22 - Uncompressed size
      // 26 - File name length (n)
      var fileNameLength = buffer.readUInt16LE(26);
      // 28 - Extra field length (m)
      var extraFieldLength = buffer.readUInt16LE(28);
      // 30 - File name
      // 30+n - Extra field
      var localFileHeaderEnd = entry.relativeOffsetOfLocalHeader + buffer.length + fileNameLength + extraFieldLength;
      var decompress;
      if (entry.compressionMethod === 0) {
        // 0 - The file is stored (no compression)
        decompress = false;
      } else if (entry.compressionMethod === 8) {
        // 8 - The file is Deflated
        decompress = options.decompress != null ? options.decompress : true;
      } else {
        return callback(new Error("unsupported compression method: " + entry.compressionMethod));
      }
      var fileDataStart = localFileHeaderEnd;
      var fileDataEnd = fileDataStart + entry.compressedSize;
      if (entry.compressedSize !== 0) {
        // bounds check now, because the read streams will probably not complain loud enough.
        // since we're dealing with an unsigned offset plus an unsigned size,
        // we only have 1 thing to check for.
        if (fileDataEnd > self.fileSize) {
          return callback(new Error("file data overflows file bounds: " +
              fileDataStart + " + " + entry.compressedSize + " > " + self.fileSize));
        }
      }
      var readStream = self.reader.createReadStream({
        start: fileDataStart + relativeStart,
        end: fileDataStart + relativeEnd,
      });
      var endpointStream = readStream;
      if (decompress) {
        var destroyed = false;
        var inflateFilter = zlib.createInflateRaw();
        readStream.on("error", function(err) {
          // setImmediate here because errors can be emitted during the first call to pipe()
          setImmediate(function() {
            if (!destroyed) inflateFilter.emit("error", err);
          });
        });
        readStream.pipe(inflateFilter);

        if (self.validateEntrySizes) {
          endpointStream = new AssertByteCountStream(entry.uncompressedSize);
          inflateFilter.on("error", function(err) {
            // forward zlib errors to the client-visible stream
            setImmediate(function() {
              if (!destroyed) endpointStream.emit("error", err);
            });
          });
          inflateFilter.pipe(endpointStream);
        } else {
          // the zlib filter is the client-visible stream
          endpointStream = inflateFilter;
        }
        // this is part of yauzl's API, so implement this function on the client-visible stream
        endpointStream.destroy = function() {
          destroyed = true;
          if (inflateFilter !== endpointStream) inflateFilter.unpipe(endpointStream);
          readStream.unpipe(inflateFilter);
          // TODO: the inflateFilter may cause a memory leak. see Issue #27.
          readStream.destroy();
        };
      }
      callback(null, endpointStream);
    } finally {
      self.reader.unref();
    }
  });
};

function Entry() {
}
Entry.prototype.getLastModDate = function() {
  return dosDateTimeToDate(this.lastModFileDate, this.lastModFileTime);
};
Entry.prototype.isEncrypted = function() {
  return (this.generalPurposeBitFlag & 0x1) !== 0;
};
Entry.prototype.isCompressed = function() {
  return this.compressionMethod === 8;
};

function dosDateTimeToDate(date, time) {
  var day = date & 0x1f; // 1-31
  var month = (date >> 5 & 0xf) - 1; // 1-12, 0-11
  var year = (date >> 9 & 0x7f) + 1980; // 0-128, 1980-2108

  var millisecond = 0;
  var second = (time & 0x1f) * 2; // 0-29, 0-58 (even numbers)
  var minute = time >> 5 & 0x3f; // 0-59
  var hour = time >> 11 & 0x1f; // 0-23

  return new Date(year, month, day, hour, minute, second, millisecond);
}

function validateFileName(fileName) {
  if (fileName.indexOf("\\") !== -1) {
    return "invalid characters in fileName: " + fileName;
  }
  if (/^[a-zA-Z]:/.test(fileName) || /^\//.test(fileName)) {
    return "absolute path: " + fileName;
  }
  if (fileName.split("/").indexOf("..") !== -1) {
    return "invalid relative path: " + fileName;
  }
  // all good
  return null;
}

function readAndAssertNoEof(reader, buffer, offset, length, position, callback) {
  if (length === 0) {
    // fs.read will throw an out-of-bounds error if you try to read 0 bytes from a 0 byte file
    return setImmediate(function() { callback(null, newBuffer(0)); });
  }
  reader.read(buffer, offset, length, position, function(err, bytesRead) {
    if (err) return callback(err);
    if (bytesRead < length) {
      return callback(new Error("unexpected EOF"));
    }
    callback();
  });
}

util.inherits(AssertByteCountStream, Transform);
function AssertByteCountStream(byteCount) {
  Transform.call(this);
  this.actualByteCount = 0;
  this.expectedByteCount = byteCount;
}
AssertByteCountStream.prototype._transform = function(chunk, encoding, cb) {
  this.actualByteCount += chunk.length;
  if (this.actualByteCount > this.expectedByteCount) {
    var msg = "too many bytes in the stream. expected " + this.expectedByteCount + ". got at least " + this.actualByteCount;
    return cb(new Error(msg));
  }
  cb(null, chunk);
};
AssertByteCountStream.prototype._flush = function(cb) {
  if (this.actualByteCount < this.expectedByteCount) {
    var msg = "not enough bytes in the stream. expected " + this.expectedByteCount + ". got only " + this.actualByteCount;
    return cb(new Error(msg));
  }
  cb();
};

util.inherits(RandomAccessReader, EventEmitter);
function RandomAccessReader() {
  EventEmitter.call(this);
  this.refCount = 0;
}
RandomAccessReader.prototype.ref = function() {
  this.refCount += 1;
};
RandomAccessReader.prototype.unref = function() {
  var self = this;
  self.refCount -= 1;

  if (self.refCount > 0) return;
  if (self.refCount < 0) throw new Error("invalid unref");

  self.close(onCloseDone);

  function onCloseDone(err) {
    if (err) return self.emit('error', err);
    self.emit('close');
  }
};
RandomAccessReader.prototype.createReadStream = function(options) {
  var start = options.start;
  var end = options.end;
  if (start === end) {
    var emptyStream = new PassThrough();
    setImmediate(function() {
      emptyStream.end();
    });
    return emptyStream;
  }
  var stream = this._readStreamForRange(start, end);

  var destroyed = false;
  var refUnrefFilter = new RefUnrefFilter(this);
  stream.on("error", function(err) {
    setImmediate(function() {
      if (!destroyed) refUnrefFilter.emit("error", err);
    });
  });
  refUnrefFilter.destroy = function() {
    stream.unpipe(refUnrefFilter);
    refUnrefFilter.unref();
    stream.destroy();
  };

  var byteCounter = new AssertByteCountStream(end - start);
  refUnrefFilter.on("error", function(err) {
    setImmediate(function() {
      if (!destroyed) byteCounter.emit("error", err);
    });
  });
  byteCounter.destroy = function() {
    destroyed = true;
    refUnrefFilter.unpipe(byteCounter);
    refUnrefFilter.destroy();
  };

  return stream.pipe(refUnrefFilter).pipe(byteCounter);
};
RandomAccessReader.prototype._readStreamForRange = function(start, end) {
  throw new Error("not implemented");
};
RandomAccessReader.prototype.read = function(buffer, offset, length, position, callback) {
  var readStream = this.createReadStream({start: position, end: position + length});
  var writeStream = new Writable();
  var written = 0;
  writeStream._write = function(chunk, encoding, cb) {
    chunk.copy(buffer, offset + written, 0, chunk.length);
    written += chunk.length;
    cb();
  };
  writeStream.on("finish", callback);
  readStream.on("error", function(error) {
    callback(error);
  });
  readStream.pipe(writeStream);
};
RandomAccessReader.prototype.close = function(callback) {
  setImmediate(callback);
};

util.inherits(RefUnrefFilter, PassThrough);
function RefUnrefFilter(context) {
  PassThrough.call(this);
  this.context = context;
  this.context.ref();
  this.unreffedYet = false;
}
RefUnrefFilter.prototype._flush = function(cb) {
  this.unref();
  cb();
};
RefUnrefFilter.prototype.unref = function(cb) {
  if (this.unreffedYet) return;
  this.unreffedYet = true;
  this.context.unref();
};

var cp437 = '\u0000☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñÑªº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ';
function decodeBuffer(buffer, start, end, isUtf8) {
  if (isUtf8) {
    return buffer.toString("utf8", start, end);
  } else {
    var result = "";
    for (var i = start; i < end; i++) {
      result += cp437[buffer[i]];
    }
    return result;
  }
}

function readUInt64LE(buffer, offset) {
  // there is no native function for this, because we can't actually store 64-bit integers precisely.
  // after 53 bits, JavaScript's Number type (IEEE 754 double) can't store individual integers anymore.
  // but since 53 bits is a whole lot more than 32 bits, we do our best anyway.
  var lower32 = buffer.readUInt32LE(offset);
  var upper32 = buffer.readUInt32LE(offset + 4);
  // we can't use bitshifting here, because JavaScript bitshifting only works on 32-bit integers.
  return upper32 * 0x100000000 + lower32;
  // as long as we're bounds checking the result of this function against the total file size,
  // we'll catch any overflow errors, because we already made sure the total file size was within reason.
}

// Node 10 deprecated new Buffer().
var newBuffer;
if (typeof Buffer.allocUnsafe === "function") {
  newBuffer = function(len) {
    return Buffer.allocUnsafe(len);
  };
} else {
  newBuffer = function(len) {
    return new Buffer(len);
  };
}

function defaultCallback(err) {
  if (err) throw err;
}


@eggjs/yauzl

description: yet another unzip library for node

lint: echo 'ignore lint'

test: node --trace-deprecation test/test.js

ci: istanbul cover --report lcovonly test/test.js

type: git

keywords: unzip zip stream archive file

author: Josh Wolfe <thejoshwolfe@gmail.com>

license: MIT

access: public

license: mit


code:
declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
export default _default;


code:
export { default as AddLocation } from './add-location.vue';
export { default as Aim } from './aim.vue';
export { default as AlarmClock } from './alarm-clock.vue';
export { default as Apple } from './apple.vue';
export { default as ArrowDownBold } from './arrow-down-bold.vue';
export { default as ArrowDown } from './arrow-down.vue';
export { default as ArrowLeftBold } from './arrow-left-bold.vue';
export { default as ArrowLeft } from './arrow-left.vue';
export { default as ArrowRightBold } from './arrow-right-bold.vue';
export { default as ArrowRight } from './arrow-right.vue';
export { default as ArrowUpBold } from './arrow-up-bold.vue';
export { default as ArrowUp } from './arrow-up.vue';
export { default as Avatar } from './avatar.vue';
export { default as Back } from './back.vue';
export { default as Baseball } from './baseball.vue';
export { default as Basketball } from './basketball.vue';
export { default as BellFilled } from './bell-filled.vue';
export { default as Bell } from './bell.vue';
export { default as Bicycle } from './bicycle.vue';
export { default as BottomLeft } from './bottom-left.vue';
export { default as BottomRight } from './bottom-right.vue';
export { default as Bottom } from './bottom.vue';
export { default as Bowl } from './bowl.vue';
export { default as Box } from './box.vue';
export { default as Briefcase } from './briefcase.vue';
export { default as BrushFilled } from './brush-filled.vue';
export { default as Brush } from './brush.vue';
export { default as Burger } from './burger.vue';
export { default as Calendar } from './calendar.vue';
export { default as CameraFilled } from './camera-filled.vue';
export { default as Camera } from './camera.vue';
export { default as CaretBottom } from './caret-bottom.vue';
export { default as CaretLeft } from './caret-left.vue';
export { default as CaretRight } from './caret-right.vue';
export { default as CaretTop } from './caret-top.vue';
export { default as Cellphone } from './cellphone.vue';
export { default as ChatDotRound } from './chat-dot-round.vue';
export { default as ChatDotSquare } from './chat-dot-square.vue';
export { default as ChatLineRound } from './chat-line-round.vue';
export { default as ChatLineSquare } from './chat-line-square.vue';
export { default as ChatRound } from './chat-round.vue';
export { default as ChatSquare } from './chat-square.vue';
export { default as Check } from './check.vue';
export { default as Checked } from './checked.vue';
export { default as Cherry } from './cherry.vue';
export { default as Chicken } from './chicken.vue';
export { default as ChromeFilled } from './chrome-filled.vue';
export { default as CircleCheckFilled } from './circle-check-filled.vue';
export { default as CircleCheck } from './circle-check.vue';
export { default as CircleCloseFilled } from './circle-close-filled.vue';
export { default as CircleClose } from './circle-close.vue';
export { default as CirclePlusFilled } from './circle-plus-filled.vue';
export { default as CirclePlus } from './circle-plus.vue';
export { default as Clock } from './clock.vue';
export { default as CloseBold } from './close-bold.vue';
export { default as Close } from './close.vue';
export { default as Cloudy } from './cloudy.vue';
export { default as CoffeeCup } from './coffee-cup.vue';
export { default as Coffee } from './coffee.vue';
export { default as Coin } from './coin.vue';
export { default as ColdDrink } from './cold-drink.vue';
export { default as CollectionTag } from './collection-tag.vue';
export { default as Collection } from './collection.vue';
export { default as Comment } from './comment.vue';
export { default as Compass } from './compass.vue';
export { default as Connection } from './connection.vue';
export { default as Coordinate } from './coordinate.vue';
export { default as CopyDocument } from './copy-document.vue';
export { default as Cpu } from './cpu.vue';
export { default as CreditCard } from './credit-card.vue';
export { default as Crop } from './crop.vue';
export { default as DArrowLeft } from './d-arrow-left.vue';
export { default as DArrowRight } from './d-arrow-right.vue';
export { default as DCaret } from './d-caret.vue';
export { default as DataAnalysis } from './data-analysis.vue';
export { default as DataBoard } from './data-board.vue';
export { default as DataLine } from './data-line.vue';
export { default as DeleteFilled } from './delete-filled.vue';
export { default as DeleteLocation } from './delete-location.vue';
export { default as Delete } from './delete.vue';
export { default as Dessert } from './dessert.vue';
export { default as Discount } from './discount.vue';
export { default as DishDot } from './dish-dot.vue';
export { default as Dish } from './dish.vue';
export { default as DocumentAdd } from './document-add.vue';
export { default as DocumentChecked } from './document-checked.vue';
export { default as DocumentCopy } from './document-copy.vue';
export { default as DocumentDelete } from './document-delete.vue';
export { default as DocumentRemove } from './document-remove.vue';
export { default as Document } from './document.vue';
export { default as Download } from './download.vue';
export { default as Drizzling } from './drizzling.vue';
export { default as EditPen } from './edit-pen.vue';
export { default as Edit } from './edit.vue';
export { default as ElemeFilled } from './eleme-filled.vue';
export { default as Eleme } from './eleme.vue';
export { default as ElementPlus } from './element-plus.vue';
export { default as Expand } from './expand.vue';
export { default as Failed } from './failed.vue';
export { default as Female } from './female.vue';
export { default as Files } from './files.vue';
export { default as Film } from './film.vue';
export { default as Filter } from './filter.vue';
export { default as Finished } from './finished.vue';
export { default as FirstAidKit } from './first-aid-kit.vue';
export { default as Flag } from './flag.vue';
export { default as Fold } from './fold.vue';
export { default as FolderAdd } from './folder-add.vue';
export { default as FolderChecked } from './folder-checked.vue';
export { default as FolderDelete } from './folder-delete.vue';
export { default as FolderOpened } from './folder-opened.vue';
export { default as FolderRemove } from './folder-remove.vue';
export { default as Folder } from './folder.vue';
export { default as Food } from './food.vue';
export { default as Football } from './football.vue';
export { default as ForkSpoon } from './fork-spoon.vue';
export { default as Fries } from './fries.vue';
export { default as FullScreen } from './full-screen.vue';
export { default as GobletFull } from './goblet-full.vue';
export { default as GobletSquareFull } from './goblet-square-full.vue';
export { default as GobletSquare } from './goblet-square.vue';
export { default as Goblet } from './goblet.vue';
export { default as GoldMedal } from './gold-medal.vue';
export { default as GoodsFilled } from './goods-filled.vue';
export { default as Goods } from './goods.vue';
export { default as Grape } from './grape.vue';
export { default as Grid } from './grid.vue';
export { default as Guide } from './guide.vue';
export { default as Handbag } from './handbag.vue';
export { default as Headset } from './headset.vue';
export { default as HelpFilled } from './help-filled.vue';
export { default as Help } from './help.vue';
export { default as Hide } from './hide.vue';
export { default as Histogram } from './histogram.vue';
export { default as HomeFilled } from './home-filled.vue';
export { default as HotWater } from './hot-water.vue';
export { default as House } from './house.vue';
export { default as IceCreamRound } from './ice-cream-round.vue';
export { default as IceCreamSquare } from './ice-cream-square.vue';
export { default as IceCream } from './ice-cream.vue';
export { default as IceDrink } from './ice-drink.vue';
export { default as IceTea } from './ice-tea.vue';
export { default as InfoFilled } from './info-filled.vue';
export { default as Iphone } from './iphone.vue';
export { default as Key } from './key.vue';
export { default as KnifeFork } from './knife-fork.vue';
export { default as Lightning } from './lightning.vue';
export { default as Link } from './link.vue';
export { default as List } from './list.vue';
export { default as Loading } from './loading.vue';
export { default as LocationFilled } from './location-filled.vue';
export { default as LocationInformation } from './location-information.vue';
export { default as Location } from './location.vue';
export { default as Lock } from './lock.vue';
export { default as Lollipop } from './lollipop.vue';
export { default as MagicStick } from './magic-stick.vue';
export { default as Magnet } from './magnet.vue';
export { default as Male } from './male.vue';
export { default as Management } from './management.vue';
export { default as MapLocation } from './map-location.vue';
export { default as Medal } from './medal.vue';
export { default as Memo } from './memo.vue';
export { default as Menu } from './menu.vue';
export { default as MessageBox } from './message-box.vue';
export { default as Message } from './message.vue';
export { default as Mic } from './mic.vue';
export { default as Microphone } from './microphone.vue';
export { default as MilkTea } from './milk-tea.vue';
export { default as Minus } from './minus.vue';
export { default as Money } from './money.vue';
export { default as Monitor } from './monitor.vue';
export { default as MoonNight } from './moon-night.vue';
export { default as Moon } from './moon.vue';
export { default as MoreFilled } from './more-filled.vue';
export { default as More } from './more.vue';
export { default as MostlyCloudy } from './mostly-cloudy.vue';
export { default as Mouse } from './mouse.vue';
export { default as Mug } from './mug.vue';
export { default as MuteNotification } from './mute-notification.vue';
export { default as Mute } from './mute.vue';
export { default as NoSmoking } from './no-smoking.vue';
export { default as Notebook } from './notebook.vue';
export { default as Notification } from './notification.vue';
export { default as Odometer } from './odometer.vue';
export { default as OfficeBuilding } from './office-building.vue';
export { default as Open } from './open.vue';
export { default as Operation } from './operation.vue';
export { default as Opportunity } from './opportunity.vue';
export { default as Orange } from './orange.vue';
export { default as Paperclip } from './paperclip.vue';
export { default as PartlyCloudy } from './partly-cloudy.vue';
export { default as Pear } from './pear.vue';
export { default as PhoneFilled } from './phone-filled.vue';
export { default as Phone } from './phone.vue';
export { default as PictureFilled } from './picture-filled.vue';
export { default as PictureRounded } from './picture-rounded.vue';
export { default as Picture } from './picture.vue';
export { default as PieChart } from './pie-chart.vue';
export { default as Place } from './place.vue';
export { default as Platform } from './platform.vue';
export { default as Plus } from './plus.vue';
export { default as Pointer } from './pointer.vue';
export { default as Position } from './position.vue';
export { default as Postcard } from './postcard.vue';
export { default as Pouring } from './pouring.vue';
export { default as Present } from './present.vue';
export { default as PriceTag } from './price-tag.vue';
export { default as Printer } from './printer.vue';
export { default as Promotion } from './promotion.vue';
export { default as QuartzWatch } from './quartz-watch.vue';
export { default as QuestionFilled } from './question-filled.vue';
export { default as Rank } from './rank.vue';
export { default as ReadingLamp } from './reading-lamp.vue';
export { default as Reading } from './reading.vue';
export { default as RefreshLeft } from './refresh-left.vue';
export { default as RefreshRight } from './refresh-right.vue';
export { default as Refresh } from './refresh.vue';
export { default as Refrigerator } from './refrigerator.vue';
export { default as RemoveFilled } from './remove-filled.vue';
export { default as Remove } from './remove.vue';
export { default as Right } from './right.vue';
export { default as ScaleToOriginal } from './scale-to-original.vue';
export { default as School } from './school.vue';
export { default as Scissor } from './scissor.vue';
export { default as Search } from './search.vue';
export { default as Select } from './select.vue';
export { default as Sell } from './sell.vue';
export { default as SemiSelect } from './semi-select.vue';
export { default as Service } from './service.vue';
export { default as SetUp } from './set-up.vue';
export { default as Setting } from './setting.vue';
export { default as Share } from './share.vue';
export { default as Ship } from './ship.vue';
export { default as Shop } from './shop.vue';
export { default as ShoppingBag } from './shopping-bag.vue';
export { default as ShoppingCartFull } from './shopping-cart-full.vue';
export { default as ShoppingCart } from './shopping-cart.vue';
export { default as ShoppingTrolley } from './shopping-trolley.vue';
export { default as Smoking } from './smoking.vue';
export { default as Soccer } from './soccer.vue';
export { default as SoldOut } from './sold-out.vue';
export { default as SortDown } from './sort-down.vue';
export { default as SortUp } from './sort-up.vue';
export { default as Sort } from './sort.vue';
export { default as Stamp } from './stamp.vue';
export { default as StarFilled } from './star-filled.vue';
export { default as Star } from './star.vue';
export { default as Stopwatch } from './stopwatch.vue';
export { default as SuccessFilled } from './success-filled.vue';
export { default as Sugar } from './sugar.vue';
export { default as SuitcaseLine } from './suitcase-line.vue';
export { default as Suitcase } from './suitcase.vue';
export { default as Sunny } from './sunny.vue';
export { default as Sunrise } from './sunrise.vue';
export { default as Sunset } from './sunset.vue';
export { default as SwitchButton } from './switch-button.vue';
export { default as SwitchFilled } from './switch-filled.vue';
export { default as Switch } from './switch.vue';
export { default as TakeawayBox } from './takeaway-box.vue';
export { default as Ticket } from './ticket.vue';
export { default as Tickets } from './tickets.vue';
export { default as Timer } from './timer.vue';
export { default as ToiletPaper } from './toilet-paper.vue';
export { default as Tools } from './tools.vue';
export { default as TopLeft } from './top-left.vue';
export { default as TopRight } from './top-right.vue';
export { default as Top } from './top.vue';
export { default as TrendCharts } from './trend-charts.vue';
export { default as TrophyBase } from './trophy-base.vue';
export { default as Trophy } from './trophy.vue';
export { default as TurnOff } from './turn-off.vue';
export { default as Umbrella } from './umbrella.vue';
export { default as Unlock } from './unlock.vue';
export { default as UploadFilled } from './upload-filled.vue';
export { default as Upload } from './upload.vue';
export { default as UserFilled } from './user-filled.vue';
export { default as User } from './user.vue';
export { default as Van } from './van.vue';
export { default as VideoCameraFilled } from './video-camera-filled.vue';
export { default as VideoCamera } from './video-camera.vue';
export { default as VideoPause } from './video-pause.vue';
export { default as VideoPlay } from './video-play.vue';
export { default as View } from './view.vue';
export { default as WalletFilled } from './wallet-filled.vue';
export { default as Wallet } from './wallet.vue';
export { default as WarnTriangleFilled } from './warn-triangle-filled.vue';
export { default as WarningFilled } from './warning-filled.vue';
export { default as Warning } from './warning.vue';
export { default as Watch } from './watch.vue';
export { default as Watermelon } from './watermelon.vue';
export { default as WindPower } from './wind-power.vue';
export { default as ZoomIn } from './zoom-in.vue';
export { default as ZoomOut } from './zoom-out.vue';


code:
import * as icons from './components';
import type { App } from 'vue';
export interface InstallOptions {
    /** @default `ElIcon` */
    prefix?: string;
}
declare const _default: (app: App, { prefix }?: InstallOptions) => void;
export default _default;
export { icons };
export * from './components';


@element-plus/icons-vue

description: Vue components of Element Plus Icons collection.

type: module

keywords: icon svg vue element-plus

directory: packages/vue

build: pnpm run build:generate && run-p build:build build:types

build:generate: tsx build/generate.ts

build:build: NODE_ENV=production tsx build/build.ts


code:
# @eslint-community/eslint-utils

[![npm version](https://img.shields.io/npm/v/@eslint-community/eslint-utils.svg)](https://www.npmjs.com/package/@eslint-community/eslint-utils)
[![Downloads/month](https://img.shields.io/npm/dm/@eslint-community/eslint-utils.svg)](http://www.npmtrends.com/@eslint-community/eslint-utils)
[![Build Status](https://github.com/eslint-community/eslint-utils/workflows/CI/badge.svg)](https://github.com/eslint-community/eslint-utils/actions)
[![Coverage Status](https://codecov.io/gh/eslint-community/eslint-utils/branch/main/graph/badge.svg)](https://codecov.io/gh/eslint-community/eslint-utils)

## 🏁 Goal

This package provides utility functions and classes for make ESLint custom rules.

For examples:

-   [`getStaticValue`](https://eslint-community.github.io/eslint-utils/api/ast-utils.html#getstaticvalue) evaluates static value on AST.
-   [`ReferenceTracker`](https://eslint-community.github.io/eslint-utils/api/scope-utils.html#referencetracker-class) checks the members of modules/globals as handling assignments and destructuring.

## 📖 Usage

See [documentation](https://eslint-community.github.io/eslint-utils).

## 📰 Changelog

See [releases](https://github.com/eslint-community/eslint-utils/releases).

## ❤ Contributing

Welcome contributing!

Please use GitHub's Issues/PRs.

### Development Tools

-   `npm test` runs tests and measures coverage.
-   `npm run clean` removes the coverage result of `npm test` command.
-   `npm run coverage` shows the coverage result of the last `npm test` command.
-   `npm run lint` runs ESLint.
-   `npm run watch` runs tests on each file change.