
Product
Introducing Rust Support in Socket
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.
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
});
The file-type package goes beyond just checking for gzip compression; it can determine the file type of a buffer/Uint8Array. This package can detect many different file types including images, videos, fonts, and more. It is more comprehensive than is-gzip, which is solely focused on gzip compression detection.
The compressible package is used to determine if a given MIME type is compressible. While it does not directly check buffers like is-gzip, it can be used in conjunction with other methods to infer if a file type is generally suitable for gzip compression.
Check if a Buffer/Uint8Array is a GZIP file
$ npm install is-gzip
const fs = require('fs');
const isGzip = require('is-gzip');
isGzip(fs.readFileSync('foo.tar.gz'));
//=> true
MIT © Kevin Mårtensson
FAQs
Check if a Buffer/Uint8Array is a GZIP file
The npm package is-gzip receives a total of 1,987,738 weekly downloads. As such, is-gzip popularity was classified as popular.
We found that is-gzip demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.
Product
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
Product
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.