nodejs zlib
const zlib = require('zlib')
/**
* @description custom compression content encoding
*/
module.exports = () => {
return (req, res, next) => {
const compressType = req.headers['accept-encoding'].replace(/[,]/g, '').split(' ')
if (compressType[0] !== undefined && compressType[0] !== null) {
zlib.createGzip({
level: zlib.constants.Z_BEST_COMPRESSION,
strategy: zlib.constants.Z_RLE,
flush: zlib.constants.Z_FULL_FLUSH
})
return next()
}
if (compressType[1] !== undefined && compressType[1] !== null) {
zlib.createDeflate({
level: zlib.constants.Z_BEST_COMPRESSION,
strategy: zlib.constants.Z_RLE,
flush: zlib.constants.Z_FULL_FLUSH
})
return next()
}
if (compressType[2] !== undefined && compressType[2] !== null) {
zlib.createBrotliCompress({
flush: zlib.constants.BROTLI_OPERATION_FLUSH
})
return next()
}
}
}
Also in JavaScript:
- javascript get clock time in auto counter up
- template literals javascript
- loading screen html css js
- javascript object tostring
- jquery is checked
- heap sort
- validate form in reactstrap modal api
- code to launch browser using javascript
- js check if div have another div
- concurrently node react
- jquery append before
- how to copy one array to another in javascript
- react quick tutorial
- span change jquery
- js tostring
- let javascript
- insert json into sql
- mv multiple directories
- how to create a folder using fs in node js
- javascript how to check if object property exists
- div click outside to hide javascript
- jquery how to expand select
- regex only uppercase letters js
- aos animation