Skip to content

Commit 45c6a4a

Browse files
authored
Bumped standard, removing var. (#137)
1 parent 3baabe9 commit 45c6a4a

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

index.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ function processCompressParams (opts) {
131131

132132
params.encodings = Array.isArray(opts.encodings)
133133
? supportedEncodings
134-
.filter(encoding => opts.encodings.includes(encoding))
135-
.sort((a, b) => opts.encodings.indexOf(a) - supportedEncodings.indexOf(b))
134+
.filter(encoding => opts.encodings.includes(encoding))
135+
.sort((a, b) => opts.encodings.indexOf(a) - supportedEncodings.indexOf(b))
136136
: supportedEncodings
137137

138138
return params
@@ -163,8 +163,8 @@ function processDecompressParams (opts) {
163163

164164
params.encodings = Array.isArray(opts.requestEncodings)
165165
? supportedEncodings
166-
.filter(encoding => opts.requestEncodings.includes(encoding))
167-
.sort((a, b) => opts.requestEncodings.indexOf(a) - supportedEncodings.indexOf(b))
166+
.filter(encoding => opts.requestEncodings.includes(encoding))
167+
.sort((a, b) => opts.requestEncodings.indexOf(a) - supportedEncodings.indexOf(b))
168168
: supportedEncodings
169169

170170
if (opts.forceRequestEncoding) {
@@ -213,8 +213,8 @@ function buildRouteCompress (fastify, params, routeOptions, decorateOnly) {
213213
}
214214
setVaryHeader(reply)
215215

216-
var stream, encoding
217-
var noCompress =
216+
let stream, encoding
217+
const noCompress =
218218
// don't compress on x-no-compression header
219219
(req.headers['x-no-compression'] !== undefined) ||
220220
// don't compress if not one of the indicated compressible types
@@ -223,9 +223,9 @@ function buildRouteCompress (fastify, params, routeOptions, decorateOnly) {
223223
((encoding = getEncodingHeader(params.encodings, req)) == null || encoding === 'identity')
224224

225225
if (encoding == null && params.onUnsupportedEncoding != null) {
226-
var encodingHeader = req.headers['accept-encoding']
226+
const encodingHeader = req.headers['accept-encoding']
227227
try {
228-
var errorPayload = params.onUnsupportedEncoding(encodingHeader, reply.request, reply)
228+
const errorPayload = params.onUnsupportedEncoding(encodingHeader, reply.request, reply)
229229
return next(null, errorPayload)
230230
} catch (err) {
231231
return next(err)
@@ -328,8 +328,8 @@ function compress (params) {
328328
}
329329

330330
setVaryHeader(this)
331-
var stream, encoding
332-
var noCompress =
331+
let stream, encoding
332+
const noCompress =
333333
// don't compress on x-no-compression header
334334
(this.request.headers['x-no-compression'] !== undefined) ||
335335
// don't compress if not one of the indicated compressible types
@@ -338,9 +338,9 @@ function compress (params) {
338338
((encoding = getEncodingHeader(params.encodings, this.request)) == null || encoding === 'identity')
339339

340340
if (encoding == null && params.onUnsupportedEncoding != null) {
341-
var encodingHeader = this.request.headers['accept-encoding']
341+
const encodingHeader = this.request.headers['accept-encoding']
342342

343-
var errorPayload
343+
let errorPayload
344344
try {
345345
errorPayload = params.onUnsupportedEncoding(encodingHeader, this.request, this)
346346
} catch (ex) {
@@ -440,7 +440,7 @@ function getEncodingHeader (encodings, request) {
440440

441441
function shouldCompress (type, compressibleTypes) {
442442
if (compressibleTypes.test(type)) return true
443-
var data = mimedb[type.split(';', 1)[0].trim().toLowerCase()]
443+
const data = mimedb[type.split(';', 1)[0].trim().toLowerCase()]
444444
if (data === undefined) return false
445445
return data.compressible === true
446446
}
@@ -455,7 +455,7 @@ function isCompressed (data) {
455455
function maybeUnzip (payload, serialize) {
456456
if (isStream(payload)) return payload
457457

458-
var buf = payload; var result = payload
458+
let buf = payload; let result = payload
459459

460460
if (ArrayBuffer.isView(payload)) {
461461
// Cast non-Buffer DataViews into a Buffer

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
"description": "Fastify compression utils",
55
"main": "index.js",
66
"dependencies": {
7-
"encoding-negotiator": "^2.0.0",
7+
"encoding-negotiator": "^2.0.1",
88
"fastify-plugin": "^3.0.0",
99
"into-stream": "^6.0.0",
1010
"is-deflate": "^1.0.0",
1111
"is-gzip": "^2.0.0",
1212
"is-stream": "^2.0.0",
1313
"is-zip": "^1.0.0",
14-
"mime-db": "^1.43.0",
14+
"mime-db": "^1.45.0",
1515
"minipass": "^3.1.1",
1616
"peek-stream": "^1.1.0",
1717
"pump": "^3.0.0",
@@ -23,10 +23,10 @@
2323
"@types/node": "^14.0.27",
2424
"@typescript-eslint/parser": "^4.0.0",
2525
"eslint-plugin-typescript": "^0.14.0",
26-
"fastify": "^3.0.0",
26+
"fastify": "^3.7.0",
2727
"jsonstream": "^1.0.3",
2828
"pre-commit": "^1.2.2",
29-
"standard": "^14.3.1",
29+
"standard": "^16.0.0",
3030
"tap": "^14.10.8",
3131
"tsd": "^0.13.1",
3232
"typescript": "^4.0.2"

0 commit comments

Comments
 (0)