function getSize(chunk) {
  return Buffer.isBuffer(chunk)
    ? chunk.length
    : Buffer.byteLength(chunk);
}
Compress:

Compress response data with gzip/deflate.

Filter:

 A `filter` callback function may be passed to
 replace the default logic of:

    exports.filter = function(req, res){
      return /json|text|javascript/.test(res.getHeader('Content-Type'));
    };

Threshold:

 Only compress the response if the byte size is at or above a threshold.
 Always compress while streaming.

  - `threshold` - string representation of size or bytes as an integer.

Options:

 All remaining options are passed to the gzip/deflate
 creation functions. Consult node's docs for additional details.

  - `chunkSize` (default: 16*1024)
  - `windowBits`
  - `level`: 0-9 where 0 is no compression, and 9 is slow but best compression
  - `memLevel`: 1-9 low is slower but uses less memory, high is fast but uses more
  - `strategy`: compression strategy

@param {Object} options
@return {Function}
@api public