How to use the adm-zip/methods/index.js.Deflater function in adm-zip

To help you get started, we’ve selected a few adm-zip examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github imlucas / lone / embed / admzip.js View on Github external
if (async && callback) callback(getCompressedDataFromZip());
                    return getCompressedDataFromZip();
                }
                if (uncompressedData.length && !_isDirectory) {
                    var compressedData;
                    switch (_entryHeader.method) {
                      case Utils.Constants.STORED:
                        _entryHeader.compressedSize = _entryHeader.size;
                        compressedData = new Buffer(uncompressedData.length);
                        uncompressedData.copy(compressedData);
                        if (async && callback) callback(compressedData);
                        return compressedData;
                        break;
                      default:
                      case Utils.Constants.DEFLATED:
                        var deflater = new Methods.Deflater(uncompressedData);
                        if (!async) {
                            var deflated = deflater.deflate();
                            _entryHeader.compressedSize = deflated.length;
                            return deflated;
                        } else {
                            deflater.deflateAsync(function(data) {
                                compressedData = new Buffer(data.length);
                                _entryHeader.compressedSize = data.length;
                                data.copy(compressedData);
                                callback && callback(compressedData);
                            });
                        }
                        deflater = null;
                        break;
                    }
                } else {