first commit

This commit is contained in:
Missdrop
2025-07-16 16:30:56 +00:00
commit 7ee33927cb
11326 changed files with 1230901 additions and 0 deletions

330
node_modules/compression/HISTORY.md generated vendored Normal file
View File

@@ -0,0 +1,330 @@
1.8.0 / 2025-02-10
==================
* Use `res.headersSent` when available
* Replace `_implicitHeader` with `writeHead` property
* add brotli support for versions of node that support it
* Add the enforceEncoding option for requests without `Accept-Encoding` header
1.7.5 / 2024-10-31
==================
* deps: Replace accepts with negotiator@~0.6.4
- Add preference option
* deps: bytes@3.1.2
- Add petabyte (`pb`) support
- Fix "thousandsSeparator" incorrecting formatting fractional part
- Fix return value for un-parsable strings
* deps: compressible@~2.0.18
- Mark `font/ttf` as compressible
- Remove compressible from `multipart/mixed`
- deps: mime-db@'>= 1.43.0 < 2'
* deps: safe-buffer@5.2.1
1.7.4 / 2019-03-18
==================
* deps: compressible@~2.0.16
- Mark `text/less` as compressible
- deps: mime-db@'>= 1.38.0 < 2'
* deps: on-headers@~1.0.2
- Fix `res.writeHead` patch missing return value
* perf: prevent unnecessary buffer copy
1.7.3 / 2018-07-15
==================
* deps: accepts@~1.3.5
- deps: mime-types@~2.1.18
* deps: compressible@~2.0.14
- Mark all XML-derived types as compressible
- deps: mime-db@'>= 1.34.0 < 2'
* deps: safe-buffer@5.1.2
1.7.2 / 2018-02-18
==================
* deps: compressible@~2.0.13
- deps: mime-db@'>= 1.33.0 < 2'
1.7.1 / 2017-09-26
==================
* deps: accepts@~1.3.4
- deps: mime-types@~2.1.16
* deps: bytes@3.0.0
* deps: compressible@~2.0.11
- deps: mime-db@'>= 1.29.0 < 2'
* deps: debug@2.6.9
* deps: vary@~1.1.2
- perf: improve header token parsing speed
1.7.0 / 2017-07-10
==================
* Use `safe-buffer` for improved Buffer API
* deps: bytes@2.5.0
* deps: compressible@~2.0.10
- Fix regex fallback to not override `compressible: false` in db
- deps: mime-db@'>= 1.27.0 < 2'
* deps: debug@2.6.8
- Allow colors in workers
- Deprecated `DEBUG_FD` environment variable set to `3` or higher
- Fix error when running under React Native
- Fix `DEBUG_MAX_ARRAY_LENGTH`
- Use same color for same namespace
- deps: ms@2.0.0
* deps: vary@~1.1.1
- perf: hoist regular expression
1.6.2 / 2016-05-12
==================
* deps: accepts@~1.3.3
- deps: mime-types@~2.1.11
- deps: negotiator@0.6.1
* deps: bytes@2.3.0
- Drop partial bytes on all parsed units
- Fix parsing byte string that looks like hex
- perf: hoist regular expressions
* deps: compressible@~2.0.8
- deps: mime-db@'>= 1.23.0 < 2'
1.6.1 / 2016-01-19
==================
* deps: bytes@2.2.0
* deps: compressible@~2.0.7
- deps: mime-db@'>= 1.21.0 < 2'
* deps: accepts@~1.3.1
- deps: mime-types@~2.1.9
1.6.0 / 2015-09-29
==================
* Skip compression when response has `Cache-Control: no-transform`
* deps: accepts@~1.3.0
- deps: mime-types@~2.1.7
- deps: negotiator@0.6.0
* deps: compressible@~2.0.6
- deps: mime-db@'>= 1.19.0 < 2'
* deps: on-headers@~1.0.1
- perf: enable strict mode
* deps: vary@~1.1.0
- Only accept valid field names in the `field` argument
1.5.2 / 2015-07-30
==================
* deps: accepts@~1.2.12
- deps: mime-types@~2.1.4
* deps: compressible@~2.0.5
- deps: mime-db@'>= 1.16.0 < 2'
* deps: vary@~1.0.1
- Fix setting empty header from empty `field`
- perf: enable strict mode
- perf: remove argument reassignments
1.5.1 / 2015-07-05
==================
* deps: accepts@~1.2.10
- deps: mime-types@~2.1.2
* deps: compressible@~2.0.4
- deps: mime-db@'>= 1.14.0 < 2'
- perf: enable strict mode
1.5.0 / 2015-06-09
==================
* Fix return value from `.end` and `.write` after end
* Improve detection of zero-length body without `Content-Length`
* deps: accepts@~1.2.9
- deps: mime-types@~2.1.1
- perf: avoid argument reassignment & argument slice
- perf: avoid negotiator recursive construction
- perf: enable strict mode
- perf: remove unnecessary bitwise operator
* deps: bytes@2.1.0
- Slight optimizations
- Units no longer case sensitive when parsing
* deps: compressible@~2.0.3
- Fix regex fallback to work if type exists, but is undefined
- deps: mime-db@'>= 1.13.0 < 2'
- perf: hoist regex declaration
- perf: use regex to extract mime
* perf: enable strict mode
* perf: remove flush reassignment
* perf: simplify threshold detection
1.4.4 / 2015-05-11
==================
* deps: accepts@~1.2.7
- deps: mime-types@~2.0.11
- deps: negotiator@0.5.3
* deps: debug@~2.2.0
- deps: ms@0.7.1
1.4.3 / 2015-03-14
==================
* deps: accepts@~1.2.5
- deps: mime-types@~2.0.10
* deps: debug@~2.1.3
- Fix high intensity foreground color for bold
- deps: ms@0.7.0
1.4.2 / 2015-03-11
==================
* Fix error when code calls `res.end(str, encoding)`
- Specific to Node.js 0.8
* deps: debug@~2.1.2
- deps: ms@0.7.0
1.4.1 / 2015-02-15
==================
* deps: accepts@~1.2.4
- deps: mime-types@~2.0.9
- deps: negotiator@0.5.1
1.4.0 / 2015-02-01
==================
* Prefer `gzip` over `deflate` on the server
- Not all clients agree on what "deflate" coding means
1.3.1 / 2015-01-31
==================
* deps: accepts@~1.2.3
- deps: mime-types@~2.0.8
* deps: compressible@~2.0.2
- deps: mime-db@'>= 1.1.2 < 2'
1.3.0 / 2014-12-30
==================
* Export the default `filter` function for wrapping
* deps: accepts@~1.2.2
- deps: mime-types@~2.0.7
- deps: negotiator@0.5.0
* deps: debug@~2.1.1
1.2.2 / 2014-12-10
==================
* Fix `.end` to only proxy to `.end`
- Fixes an issue with Node.js 0.11.14
* deps: accepts@~1.1.4
- deps: mime-types@~2.0.4
1.2.1 / 2014-11-23
==================
* deps: accepts@~1.1.3
- deps: mime-types@~2.0.3
1.2.0 / 2014-10-16
==================
* deps: debug@~2.1.0
- Implement `DEBUG_FD` env variable support
1.1.2 / 2014-10-15
==================
* deps: accepts@~1.1.2
- Fix error when media type has invalid parameter
- deps: negotiator@0.4.9
1.1.1 / 2014-10-12
==================
* deps: accepts@~1.1.1
- deps: mime-types@~2.0.2
- deps: negotiator@0.4.8
* deps: compressible@~2.0.1
- deps: mime-db@1.x
1.1.0 / 2014-09-07
==================
* deps: accepts@~1.1.0
* deps: compressible@~2.0.0
* deps: debug@~2.0.0
1.0.11 / 2014-08-10
===================
* deps: on-headers@~1.0.0
* deps: vary@~1.0.0
1.0.10 / 2014-08-05
===================
* deps: compressible@~1.1.1
- Fix upper-case Content-Type characters prevent compression
1.0.9 / 2014-07-20
==================
* Add `debug` messages
* deps: accepts@~1.0.7
- deps: negotiator@0.4.7
1.0.8 / 2014-06-20
==================
* deps: accepts@~1.0.5
- use `mime-types`
1.0.7 / 2014-06-11
==================
* use vary module for better `Vary` behavior
* deps: accepts@1.0.3
* deps: compressible@1.1.0
1.0.6 / 2014-06-03
==================
* fix regression when negotiation fails
1.0.5 / 2014-06-03
==================
* fix listeners for delayed stream creation
- fixes regression for certain `stream.pipe(res)` situations
1.0.4 / 2014-06-03
==================
* fix adding `Vary` when value stored as array
* fix back-pressure behavior
* fix length check for `res.end`
1.0.3 / 2014-05-29
==================
* use `accepts` for negotiation
* use `on-headers` to handle header checking
* deps: bytes@1.0.0
1.0.2 / 2014-04-29
==================
* only version compatible with node.js 0.8
* support headers given to `res.writeHead`
* deps: bytes@0.3.0
* deps: negotiator@0.4.3
1.0.1 / 2014-03-08
==================
* bump negotiator
* use compressible
* use .headersSent (drops 0.8 support)
* handle identity;q=0 case

23
node_modules/compression/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,23 @@
(The MIT License)
Copyright (c) 2014 Jonathan Ong <me@jongleberry.com>
Copyright (c) 2014-2015 Douglas Christopher Wilson <doug@somethingdoug.com>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

311
node_modules/compression/README.md generated vendored Normal file
View File

@@ -0,0 +1,311 @@
# compression
[![NPM Version][npm-image]][npm-url]
[![NPM Downloads][downloads-image]][downloads-url]
[![Build Status][github-actions-ci-image]][github-actions-ci-url]
[![OpenSSF Scorecard Badge][ossf-scorecard-badge]][ossf-scorecard-visualizer]
[![Funding][funding-image]][funding-url]
Node.js compression middleware.
The following compression codings are supported:
- deflate
- gzip
- br (brotli)
**Note** Brotli is supported only since Node.js versions v11.7.0 and v10.16.0.
## Install
This is a [Node.js](https://nodejs.org/en/) module available through the
[npm registry](https://www.npmjs.com/). Installation is done using the
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
```bash
$ npm install compression
```
## API
```js
var compression = require('compression')
```
### compression([options])
Returns the compression middleware using the given `options`. The middleware
will attempt to compress response bodies for all requests that traverse through
the middleware, based on the given `options`.
This middleware will never compress responses that include a `Cache-Control`
header with the [`no-transform` directive](https://tools.ietf.org/html/rfc7234#section-5.2.2.4),
as compressing will transform the body.
#### Options
`compression()` accepts these properties in the options object. In addition to
those listed below, [zlib](http://nodejs.org/api/zlib.html) options may be
passed in to the options object or
[brotli](https://nodejs.org/api/zlib.html#zlib_class_brotlioptions) options.
##### chunkSize
Type: `Number`<br>
Default: `zlib.constants.Z_DEFAULT_CHUNK`, or `16384`.
See [Node.js documentation](http://nodejs.org/api/zlib.html#zlib_memory_usage_tuning)
regarding the usage.
##### filter
Type: `Function`
A function to decide if the response should be considered for compression.
This function is called as `filter(req, res)` and is expected to return
`true` to consider the response for compression, or `false` to not compress
the response.
The default filter function uses the [compressible](https://www.npmjs.com/package/compressible)
module to determine if `res.getHeader('Content-Type')` is compressible.
##### level
Type: `Number`<br>
Default: `zlib.constants.Z_DEFAULT_COMPRESSION`, or `-1`
The level of zlib compression to apply to responses. A higher level will result
in better compression, but will take longer to complete. A lower level will
result in less compression, but will be much faster.
This is an integer in the range of `0` (no compression) to `9` (maximum
compression). The special value `-1` can be used to mean the "default
compression level", which is a default compromise between speed and
compression (currently equivalent to level 6).
- `-1` Default compression level (also `zlib.constants.Z_DEFAULT_COMPRESSION`).
- `0` No compression (also `zlib.constants.Z_NO_COMPRESSION`).
- `1` Fastest compression (also `zlib.constants.Z_BEST_SPEED`).
- `2`
- `3`
- `4`
- `5`
- `6` (currently what `zlib.constants.Z_DEFAULT_COMPRESSION` points to).
- `7`
- `8`
- `9` Best compression (also `zlib.constants.Z_BEST_COMPRESSION`).
**Note** in the list above, `zlib` is from `zlib = require('zlib')`.
##### memLevel
Type: `Number`<br>
Default: `zlib.constants.Z_DEFAULT_MEMLEVEL`, or `8`
This specifies how much memory should be allocated for the internal compression
state and is an integer in the range of `1` (minimum level) and `9` (maximum
level).
See [Node.js documentation](http://nodejs.org/api/zlib.html#zlib_memory_usage_tuning)
regarding the usage.
##### brotli
Type: `Object`
This specifies the options for configuring Brotli. See [Node.js documentation](https://nodejs.org/api/zlib.html#class-brotlioptions) for a complete list of available options.
##### strategy
Type: `Number`<br>
Default: `zlib.constants.Z_DEFAULT_STRATEGY`
This is used to tune the compression algorithm. This value only affects the
compression ratio, not the correctness of the compressed output, even if it
is not set appropriately.
- `zlib.constants.Z_DEFAULT_STRATEGY` Use for normal data.
- `zlib.constants.Z_FILTERED` Use for data produced by a filter (or predictor).
Filtered data consists mostly of small values with a somewhat random
distribution. In this case, the compression algorithm is tuned to
compress them better. The effect is to force more Huffman coding and less
string matching; it is somewhat intermediate between `zlib.constants.Z_DEFAULT_STRATEGY`
and `zlib.constants.Z_HUFFMAN_ONLY`.
- `zlib.constants.Z_FIXED` Use to prevent the use of dynamic Huffman codes, allowing
for a simpler decoder for special applications.
- `zlib.constants.Z_HUFFMAN_ONLY` Use to force Huffman encoding only (no string match).
- `zlib.constants.Z_RLE` Use to limit match distances to one (run-length encoding).
This is designed to be almost as fast as `zlib.constants.Z_HUFFMAN_ONLY`, but give
better compression for PNG image data.
**Note** in the list above, `zlib` is from `zlib = require('zlib')`.
##### threshold
Type: `Number` or `String`<br>
Default: `1kb`
The byte threshold for the response body size before compression is considered
for the response. This is a number of bytes or any string
accepted by the [bytes](https://www.npmjs.com/package/bytes) module.
**Note** this is only an advisory setting; if the response size cannot be determined
at the time the response headers are written, then it is assumed the response is
_over_ the threshold. To guarantee the response size can be determined, be sure
set a `Content-Length` response header.
##### windowBits
Type: `Number`<br>
Default: `zlib.constants.Z_DEFAULT_WINDOWBITS`, or `15`
See [Node.js documentation](http://nodejs.org/api/zlib.html#zlib_memory_usage_tuning)
regarding the usage.
##### enforceEncoding
Type: `String`<br>
Default: `identity`
This is the default encoding to use when the client does not specify an encoding in the request's [Accept-Encoding](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding) header.
#### .filter
The default `filter` function. This is used to construct a custom filter
function that is an extension of the default function.
```js
var compression = require('compression')
var express = require('express')
var app = express()
app.use(compression({ filter: shouldCompress }))
function shouldCompress (req, res) {
if (req.headers['x-no-compression']) {
// don't compress responses with this request header
return false
}
// fallback to standard filter function
return compression.filter(req, res)
}
```
### res.flush
This module adds a `res.flush()` method to force the partially-compressed
response to be flushed to the client.
## Examples
### express
When using this module with express, simply `app.use` the module as
high as you like. Requests that pass through the middleware will be compressed.
```js
var compression = require('compression')
var express = require('express')
var app = express()
// compress all responses
app.use(compression())
// add all routes
```
### Node.js HTTP server
```js
var compression = require('compression')({ threshold: 0 })
var http = require('http')
function createServer (fn) {
return http.createServer(function (req, res) {
compression(req, res, function (err) {
if (err) {
res.statusCode = err.status || 500
res.end(err.message)
return
}
fn(req, res)
})
})
}
var server = createServer(function (req, res) {
res.setHeader('Content-Type', 'text/plain')
res.end('hello world!')
})
server.listen(3000, () => {
console.log('> Listening at http://localhost:3000')
})
```
### Server-Sent Events
Because of the nature of compression this module does not work out of the box
with server-sent events. To compress content, a window of the output needs to
be buffered up in order to get good compression. Typically when using server-sent
events, there are certain block of data that need to reach the client.
You can achieve this by calling `res.flush()` when you need the data written to
actually make it to the client.
```js
var compression = require('compression')
var express = require('express')
var app = express()
// compress responses
app.use(compression())
// server-sent event stream
app.get('/events', function (req, res) {
res.setHeader('Content-Type', 'text/event-stream')
res.setHeader('Cache-Control', 'no-cache')
// send a ping approx every 2 seconds
var timer = setInterval(function () {
res.write('data: ping\n\n')
// !!! this is the important part
res.flush()
}, 2000)
res.on('close', function () {
clearInterval(timer)
})
})
```
## Contributing
The Express.js project welcomes all constructive contributions. Contributions take many forms,
from code for bug fixes and enhancements, to additions and fixes to documentation, additional
tests, triaging incoming pull requests and issues, and more!
See the [Contributing Guide](https://github.com/expressjs/express/blob/master/Contributing.md) for more technical details on contributing.
## License
[MIT](LICENSE)
[npm-image]: https://badgen.net/npm/v/compression
[npm-url]: https://npmjs.org/package/compression
[downloads-image]: https://badgen.net/npm/dm/compression
[downloads-url]: https://npmcharts.com/compare/compression?minimal=true
[github-actions-ci-image]: https://badgen.net/github/checks/expressjs/compression/master?label=CI
[github-actions-ci-url]: https://github.com/expressjs/compression/actions?query=workflow%3Aci
[ossf-scorecard-badge]: https://api.scorecard.dev/projects/github.com/expressjs/compression/badge
[ossf-scorecard-visualizer]: https://ossf.github.io/scorecard-visualizer/#/projects/github.com/expressjs/compression
[funding-url]: https://opencollective.com/express
[funding-image]: https://badgen.net/badge/icon/sponsor/pink?icon=github&label=Open%20Collective

325
node_modules/compression/index.js generated vendored Normal file
View File

@@ -0,0 +1,325 @@
/*!
* compression
* Copyright(c) 2010 Sencha Inc.
* Copyright(c) 2011 TJ Holowaychuk
* Copyright(c) 2014 Jonathan Ong
* Copyright(c) 2014-2015 Douglas Christopher Wilson
* MIT Licensed
*/
'use strict'
/**
* Module dependencies.
* @private
*/
var Negotiator = require('negotiator')
var Buffer = require('safe-buffer').Buffer
var bytes = require('bytes')
var compressible = require('compressible')
var debug = require('debug')('compression')
var onHeaders = require('on-headers')
var vary = require('vary')
var zlib = require('zlib')
/**
* Module exports.
*/
module.exports = compression
module.exports.filter = shouldCompress
/**
* @const
* whether current node version has brotli support
*/
var hasBrotliSupport = 'createBrotliCompress' in zlib
/**
* Module variables.
* @private
*/
var cacheControlNoTransformRegExp = /(?:^|,)\s*?no-transform\s*?(?:,|$)/
var SUPPORTED_ENCODING = hasBrotliSupport ? ['br', 'gzip', 'deflate', 'identity'] : ['gzip', 'deflate', 'identity']
var PREFERRED_ENCODING = hasBrotliSupport ? ['br', 'gzip'] : ['gzip']
var encodingSupported = ['gzip', 'deflate', 'identity', 'br']
/**
* Compress response data with gzip / deflate.
*
* @param {Object} [options]
* @return {Function} middleware
* @public
*/
function compression (options) {
var opts = options || {}
var optsBrotli = {}
if (hasBrotliSupport) {
Object.assign(optsBrotli, opts.brotli)
var brotliParams = {}
brotliParams[zlib.constants.BROTLI_PARAM_QUALITY] = 4
// set the default level to a reasonable value with balanced speed/ratio
optsBrotli.params = Object.assign(brotliParams, optsBrotli.params)
}
// options
var filter = opts.filter || shouldCompress
var threshold = bytes.parse(opts.threshold)
var enforceEncoding = opts.enforceEncoding || 'identity'
if (threshold == null) {
threshold = 1024
}
return function compression (req, res, next) {
var ended = false
var length
var listeners = []
var stream
var _end = res.end
var _on = res.on
var _write = res.write
// flush
res.flush = function flush () {
if (stream) {
stream.flush()
}
}
// proxy
res.write = function write (chunk, encoding) {
if (ended) {
return false
}
if (!headersSent(res)) {
this.writeHead(this.statusCode)
}
return stream
? stream.write(toBuffer(chunk, encoding))
: _write.call(this, chunk, encoding)
}
res.end = function end (chunk, encoding) {
if (ended) {
return false
}
if (!headersSent(res)) {
// estimate the length
if (!this.getHeader('Content-Length')) {
length = chunkLength(chunk, encoding)
}
this.writeHead(this.statusCode)
}
if (!stream) {
return _end.call(this, chunk, encoding)
}
// mark ended
ended = true
// write Buffer for Node.js 0.8
return chunk
? stream.end(toBuffer(chunk, encoding))
: stream.end()
}
res.on = function on (type, listener) {
if (!listeners || type !== 'drain') {
return _on.call(this, type, listener)
}
if (stream) {
return stream.on(type, listener)
}
// buffer listeners for future stream
listeners.push([type, listener])
return this
}
function nocompress (msg) {
debug('no compression: %s', msg)
addListeners(res, _on, listeners)
listeners = null
}
onHeaders(res, function onResponseHeaders () {
// determine if request is filtered
if (!filter(req, res)) {
nocompress('filtered')
return
}
// determine if the entity should be transformed
if (!shouldTransform(req, res)) {
nocompress('no transform')
return
}
// vary
vary(res, 'Accept-Encoding')
// content-length below threshold
if (Number(res.getHeader('Content-Length')) < threshold || length < threshold) {
nocompress('size below threshold')
return
}
var encoding = res.getHeader('Content-Encoding') || 'identity'
// already encoded
if (encoding !== 'identity') {
nocompress('already encoded')
return
}
// head
if (req.method === 'HEAD') {
nocompress('HEAD request')
return
}
// compression method
var negotiator = new Negotiator(req)
var method = negotiator.encoding(SUPPORTED_ENCODING, PREFERRED_ENCODING)
// if no method is found, use the default encoding
if (!req.headers['accept-encoding'] && encodingSupported.indexOf(enforceEncoding) !== -1) {
method = enforceEncoding
}
// negotiation failed
if (!method || method === 'identity') {
nocompress('not acceptable')
return
}
// compression stream
debug('%s compression', method)
stream = method === 'gzip'
? zlib.createGzip(opts)
: method === 'br'
? zlib.createBrotliCompress(optsBrotli)
: zlib.createDeflate(opts)
// add buffered listeners to stream
addListeners(stream, stream.on, listeners)
// header fields
res.setHeader('Content-Encoding', method)
res.removeHeader('Content-Length')
// compression
stream.on('data', function onStreamData (chunk) {
if (_write.call(res, chunk) === false) {
stream.pause()
}
})
stream.on('end', function onStreamEnd () {
_end.call(res)
})
_on.call(res, 'drain', function onResponseDrain () {
stream.resume()
})
})
next()
}
}
/**
* Add bufferred listeners to stream
* @private
*/
function addListeners (stream, on, listeners) {
for (var i = 0; i < listeners.length; i++) {
on.apply(stream, listeners[i])
}
}
/**
* Get the length of a given chunk
*/
function chunkLength (chunk, encoding) {
if (!chunk) {
return 0
}
return Buffer.isBuffer(chunk)
? chunk.length
: Buffer.byteLength(chunk, encoding)
}
/**
* Default filter function.
* @private
*/
function shouldCompress (req, res) {
var type = res.getHeader('Content-Type')
if (type === undefined || !compressible(type)) {
debug('%s not compressible', type)
return false
}
return true
}
/**
* Determine if the entity should be transformed.
* @private
*/
function shouldTransform (req, res) {
var cacheControl = res.getHeader('Cache-Control')
// Don't compress for Cache-Control: no-transform
// https://tools.ietf.org/html/rfc7234#section-5.2.2.4
return !cacheControl ||
!cacheControlNoTransformRegExp.test(cacheControl)
}
/**
* Coerce arguments to Buffer
* @private
*/
function toBuffer (chunk, encoding) {
return Buffer.isBuffer(chunk)
? chunk
: Buffer.from(chunk, encoding)
}
/**
* Determine if the response headers have been sent.
*
* @param {object} res
* @returns {boolean}
* @private
*/
function headersSent (res) {
return typeof res.headersSent !== 'boolean'
? Boolean(res._header)
: res.headersSent
}

48
node_modules/compression/package.json generated vendored Normal file
View File

@@ -0,0 +1,48 @@
{
"name": "compression",
"description": "Node.js compression middleware",
"version": "1.8.0",
"contributors": [
"Douglas Christopher Wilson <doug@somethingdoug.com>",
"Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)"
],
"license": "MIT",
"repository": "expressjs/compression",
"keywords": ["compression", "gzip", "deflate", "middleware", "express", "brotli", "http", "stream"],
"dependencies": {
"bytes": "3.1.2",
"compressible": "~2.0.18",
"debug": "2.6.9",
"negotiator": "~0.6.4",
"on-headers": "~1.0.2",
"safe-buffer": "5.2.1",
"vary": "~1.1.2"
},
"devDependencies": {
"after": "0.8.2",
"eslint": "7.32.0",
"eslint-config-standard": "14.1.1",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-markdown": "2.2.1",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-promise": "5.2.0",
"eslint-plugin-standard": "4.1.0",
"mocha": "9.2.2",
"nyc": "15.1.0",
"supertest": "6.2.3"
},
"files": [
"LICENSE",
"HISTORY.md",
"index.js"
],
"engines": {
"node": ">= 0.8.0"
},
"scripts": {
"lint": "eslint .",
"test": "mocha --check-leaks --reporter spec",
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
"test-cov": "nyc --reporter=html --reporter=text npm test"
}
}