This commit is contained in:
Flummi 2025-03-18 13:25:26 +01:00
parent 694c2336b3
commit 3f1effbb4a
2 changed files with 8 additions and 12 deletions

10
dist/index.js vendored
View File

@ -4,12 +4,10 @@ import { URL } from "url";
import querystring from "querystring"; import querystring from "querystring";
import zlib from "zlib"; import zlib from "zlib";
const decompress = (data, encoding) => { const decompress = (data, encoding) => {
switch (encoding) { return encoding === "br" ? zlib.brotliDecompressSync(data) :
case "br": return zlib.brotliDecompressSync(data); encoding === "gzip" ? zlib.gunzipSync(data) :
case "gzip": return zlib.gunzipSync(data); encoding === "deflate" ? zlib.inflateSync(data) :
case "deflate": return zlib.inflateSync(data); data;
}
return data;
}; };
const readData = (res, mode) => new Promise((resolve, reject) => { const readData = (res, mode) => new Promise((resolve, reject) => {
const chunks = []; const chunks = [];

View File

@ -22,12 +22,10 @@ const decompress = (
data: Buffer, data: Buffer,
encoding: string | undefined encoding: string | undefined
): Buffer => { ): Buffer => {
switch(encoding) { return encoding === "br" ? zlib.brotliDecompressSync(data) :
case "br": return zlib.brotliDecompressSync(data); encoding === "gzip" ? zlib.gunzipSync(data) :
case "gzip": return zlib.gunzipSync(data); encoding === "deflate" ? zlib.inflateSync(data) :
case "deflate": return zlib.inflateSync(data); data;
}
return data;
}; };
const readData = <T>( const readData = <T>(