is-gzip-stream

    0.2.1 • Public • Published

    is-gzip-stream

    Build Test Coverage Code Climate Downloads Version ISC License

    Install

    npm install --save is-gzip-stream
    

    Usage

    You can pass any readable stream into the module to determine if the stream contains gzipped content.

    The module has to read some of the stream, meaning that you will not be able to use the entire stream if you wait to determine if the content is gzipped or not. To read the stream, you will need to use the stream provided by the lib. It is available both as a return value and in the callback, just in case.

    var fs = require('fs');
    var isGzipStream = require('is-gzip-stream');
     
    var stream = fs.createReadStream('somefile');
     
    stream = isGzipStream(stream, function(err, isGzipped) {
        // if there is no error, isGzipped will be a boolean
        
        // stream can provide the entire content of the original file
        // you can read the data as normal
    });
    var fs = require('fs');
    var isGzipStream = require('is-gzip-stream');
     
    var unknownStream = fs.createReadStream('somefile');
     
    isGzipStream(unknownStream, function(err, isGzipped, knownStream) {
        // if there is no error, isGzipped will be a boolean
        
        // knownStream can provide the entire content of the original file,
        // and you can read it like normal
        
        // the original `stream` variable is still the same, though some data
        // has been read already, and you will not get the entire file if you
        // begin reading now
    });

    License

    ISC

    Keywords

    Install

    npm i is-gzip-stream

    DownloadsWeekly Downloads

    4

    Version

    0.2.1

    License

    ISC

    Last publish

    Collaborators

    • kirilv