What is is-gzip?
The is-gzip npm package is a simple utility that allows you to check if a given buffer is compressed using the gzip compression algorithm. It is useful when you need to determine the compression of data programmatically, especially when dealing with streams or files that may or may not be gzipped.
Check if a buffer is gzipped
This feature allows you to check if a buffer (for example, the contents of a file read into memory) is gzipped. The function returns a boolean value indicating whether the buffer is gzipped or not.
const isGzip = require('is-gzip');
const fs = require('fs');
fs.readFile('file.gz', (err, data) => {
if (err) throw err;
console.log(isGzip(data)); // true or false
});