How to use the adm-zip/methods/index.js.Inflater 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
}
                var data = new Buffer(_entryHeader.size);
                data.fill(0);
                switch (_entryHeader.method) {
                  case Utils.Constants.STORED:
                    compressedData.copy(data);
                    if (!crc32OK(data)) {
                        if (async && callback) callback(data, Utils.Errors.BAD_CRC);
                        return Utils.Errors.BAD_CRC;
                    } else {
                        if (async && callback) callback(data);
                        return data;
                    }
                    break;
                  case Utils.Constants.DEFLATED:
                    var inflater = new Methods.Inflater(compressedData);
                    if (!async) {
                        inflater.inflate(data);
                        if (!crc32OK(data)) {
                            console.warn(Utils.Errors.BAD_CRC + " " + _entryName.toString());
                        }
                        return data;
                    } else {
                        inflater.inflateAsync(function(result) {
                            result.copy(data, 0);
                            if (crc32OK(data)) {
                                if (callback) callback(data, Utils.Errors.BAD_CRC);
                            } else {
                                if (callback) callback(data);
                            }
                        });
                    }