format: prettify entire project
This commit is contained in:
2
node_modules/decompress-response/index.d.ts
generated
vendored
2
node_modules/decompress-response/index.d.ts
generated
vendored
@ -1,5 +1,5 @@
|
||||
/// <reference types="node"/>
|
||||
import {IncomingMessage} from 'http';
|
||||
import { IncomingMessage } from 'http';
|
||||
|
||||
/**
|
||||
Decompress a HTTP response if needed.
|
||||
|
83
node_modules/decompress-response/index.js
generated
vendored
83
node_modules/decompress-response/index.js
generated
vendored
@ -1,58 +1,61 @@
|
||||
'use strict';
|
||||
const {Transform, PassThrough} = require('stream');
|
||||
const { Transform, PassThrough } = require('stream');
|
||||
const zlib = require('zlib');
|
||||
const mimicResponse = require('mimic-response');
|
||||
|
||||
module.exports = response => {
|
||||
const contentEncoding = (response.headers['content-encoding'] || '').toLowerCase();
|
||||
module.exports = (response) => {
|
||||
const contentEncoding = (
|
||||
response.headers['content-encoding'] || ''
|
||||
).toLowerCase();
|
||||
|
||||
if (!['gzip', 'deflate', 'br'].includes(contentEncoding)) {
|
||||
return response;
|
||||
}
|
||||
if (!['gzip', 'deflate', 'br'].includes(contentEncoding)) {
|
||||
return response;
|
||||
}
|
||||
|
||||
// TODO: Remove this when targeting Node.js 12.
|
||||
const isBrotli = contentEncoding === 'br';
|
||||
if (isBrotli && typeof zlib.createBrotliDecompress !== 'function') {
|
||||
response.destroy(new Error('Brotli is not supported on Node.js < 12'));
|
||||
return response;
|
||||
}
|
||||
// TODO: Remove this when targeting Node.js 12.
|
||||
const isBrotli = contentEncoding === 'br';
|
||||
if (isBrotli && typeof zlib.createBrotliDecompress !== 'function') {
|
||||
response.destroy(new Error('Brotli is not supported on Node.js < 12'));
|
||||
return response;
|
||||
}
|
||||
|
||||
let isEmpty = true;
|
||||
let isEmpty = true;
|
||||
|
||||
const checker = new Transform({
|
||||
transform(data, _encoding, callback) {
|
||||
isEmpty = false;
|
||||
const checker = new Transform({
|
||||
transform(data, _encoding, callback) {
|
||||
isEmpty = false;
|
||||
|
||||
callback(null, data);
|
||||
},
|
||||
callback(null, data);
|
||||
},
|
||||
|
||||
flush(callback) {
|
||||
callback();
|
||||
}
|
||||
});
|
||||
flush(callback) {
|
||||
callback();
|
||||
},
|
||||
});
|
||||
|
||||
const finalStream = new PassThrough({
|
||||
autoDestroy: false,
|
||||
destroy(error, callback) {
|
||||
response.destroy();
|
||||
const finalStream = new PassThrough({
|
||||
autoDestroy: false,
|
||||
destroy(error, callback) {
|
||||
response.destroy();
|
||||
|
||||
callback(error);
|
||||
}
|
||||
});
|
||||
callback(error);
|
||||
},
|
||||
});
|
||||
|
||||
const decompressStream = isBrotli ? zlib.createBrotliDecompress() : zlib.createUnzip();
|
||||
const decompressStream =
|
||||
isBrotli ? zlib.createBrotliDecompress() : zlib.createUnzip();
|
||||
|
||||
decompressStream.once('error', error => {
|
||||
if (isEmpty && !response.readable) {
|
||||
finalStream.end();
|
||||
return;
|
||||
}
|
||||
decompressStream.once('error', (error) => {
|
||||
if (isEmpty && !response.readable) {
|
||||
finalStream.end();
|
||||
return;
|
||||
}
|
||||
|
||||
finalStream.destroy(error);
|
||||
});
|
||||
finalStream.destroy(error);
|
||||
});
|
||||
|
||||
mimicResponse(response, finalStream);
|
||||
response.pipe(checker).pipe(decompressStream).pipe(finalStream);
|
||||
mimicResponse(response, finalStream);
|
||||
response.pipe(checker).pipe(decompressStream).pipe(finalStream);
|
||||
|
||||
return finalStream;
|
||||
return finalStream;
|
||||
};
|
||||
|
108
node_modules/decompress-response/package.json
generated
vendored
108
node_modules/decompress-response/package.json
generated
vendored
@ -1,56 +1,56 @@
|
||||
{
|
||||
"name": "decompress-response",
|
||||
"version": "6.0.0",
|
||||
"description": "Decompress a HTTP response if needed",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/decompress-response",
|
||||
"funding": "https://github.com/sponsors/sindresorhus",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"decompress",
|
||||
"response",
|
||||
"http",
|
||||
"https",
|
||||
"zlib",
|
||||
"gzip",
|
||||
"zip",
|
||||
"deflate",
|
||||
"unzip",
|
||||
"ungzip",
|
||||
"incoming",
|
||||
"message",
|
||||
"stream",
|
||||
"compressed",
|
||||
"brotli"
|
||||
],
|
||||
"dependencies": {
|
||||
"mimic-response": "^3.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^14.0.1",
|
||||
"ava": "^2.2.0",
|
||||
"get-stream": "^5.0.0",
|
||||
"pify": "^5.0.0",
|
||||
"tsd": "^0.11.0",
|
||||
"xo": "^0.30.0"
|
||||
},
|
||||
"xo": {
|
||||
"rules": {
|
||||
"@typescript-eslint/prefer-readonly-parameter-types": "off"
|
||||
}
|
||||
}
|
||||
"name": "decompress-response",
|
||||
"version": "6.0.0",
|
||||
"description": "Decompress a HTTP response if needed",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/decompress-response",
|
||||
"funding": "https://github.com/sponsors/sindresorhus",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"decompress",
|
||||
"response",
|
||||
"http",
|
||||
"https",
|
||||
"zlib",
|
||||
"gzip",
|
||||
"zip",
|
||||
"deflate",
|
||||
"unzip",
|
||||
"ungzip",
|
||||
"incoming",
|
||||
"message",
|
||||
"stream",
|
||||
"compressed",
|
||||
"brotli"
|
||||
],
|
||||
"dependencies": {
|
||||
"mimic-response": "^3.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^14.0.1",
|
||||
"ava": "^2.2.0",
|
||||
"get-stream": "^5.0.0",
|
||||
"pify": "^5.0.0",
|
||||
"tsd": "^0.11.0",
|
||||
"xo": "^0.30.0"
|
||||
},
|
||||
"xo": {
|
||||
"rules": {
|
||||
"@typescript-eslint/prefer-readonly-parameter-types": "off"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user