Skip to content

Commit

Permalink
fixed lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Icehunter committed Jul 30, 2022
1 parent d85e6e8 commit 0dafcad
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 177 deletions.
23 changes: 6 additions & 17 deletions index.js
Expand Up @@ -84,9 +84,7 @@ function compression (options) {
this.writeHead(this.statusCode)
}

return stream
? stream.write(toBuffer(chunk, encoding))
: _write.call(this, chunk, encoding)
return stream ? stream.write(toBuffer(chunk, encoding)) : _write.call(this, chunk, encoding)
}

res.end = function end (chunk, encoding) {
Expand All @@ -111,9 +109,7 @@ function compression (options) {
ended = true

// write Buffer for Node.js 0.8
return chunk
? stream.end(toBuffer(chunk, encoding))
: stream.end()
return chunk ? stream.end(toBuffer(chunk, encoding)) : stream.end()
}

res.on = function on (type, listener) {
Expand Down Expand Up @@ -190,9 +186,7 @@ function compression (options) {

// compression stream
debug('%s compression', method)
stream = method === 'gzip'
? zlib.createGzip(opts)
: zlib.createDeflate(opts)
stream = method === 'gzip' ? zlib.createGzip(opts) : zlib.createDeflate(opts)

// add buffered listeners to stream
addListeners(stream, stream.on, listeners)
Expand Down Expand Up @@ -241,9 +235,7 @@ function chunkLength (chunk, encoding) {
return 0
}

return !Buffer.isBuffer(chunk)
? Buffer.byteLength(chunk, encoding)
: chunk.length
return !Buffer.isBuffer(chunk) ? Buffer.byteLength(chunk, encoding) : chunk.length
}

/**
Expand Down Expand Up @@ -272,8 +264,7 @@ function shouldTransform (req, res) {

// Don't compress for Cache-Control: no-transform
// https://tools.ietf.org/html/rfc7234#section-5.2.2.4
return !cacheControl ||
!cacheControlNoTransformRegExp.test(cacheControl)
return !cacheControl || !cacheControlNoTransformRegExp.test(cacheControl)
}

/**
Expand All @@ -282,7 +273,5 @@ function shouldTransform (req, res) {
*/

function toBuffer (chunk, encoding) {
return !Buffer.isBuffer(chunk)
? Buffer.from(chunk, encoding)
: chunk
return !Buffer.isBuffer(chunk) ? Buffer.from(chunk, encoding) : chunk
}

0 comments on commit 0dafcad

Please sign in to comment.