| 76890 | return unzip; |
| 76891 | } else if (contentEncoding === "deflate") { |
| 76892 | const inflate = zlib2.createInflate(); |
| 76893 | stream4.pipe(inflate); |
| 76894 | return inflate; |
| 76895 | } |
| 76896 | return stream4; |
| 76897 | } |
| 76898 | function streamToText(stream4) { |
| 76899 | return new Promise((resolve, reject) => { |
| 76900 | const buffer = []; |
| 76901 | stream4.on("data", (chunk) => { |
| 76902 | if (Buffer.isBuffer(chunk)) { |
| 76903 | buffer.push(chunk); |
| 76904 | } else { |
| 76905 | buffer.push(Buffer.from(chunk)); |
| 76906 | } |
| 76907 | }); |
| 76908 | stream4.on("end", () => { |
| 76909 | resolve(Buffer.concat(buffer).toString("utf8")); |
| 76910 | }); |
| 76911 | stream4.on("error", (e3) => { |
| 76912 | if (e3 && (e3 === null || e3 === void 0 ? void 0 : e3.name) === "AbortError") { |
| 76913 | reject(e3); |
| 76914 | } else { |
| 76915 | reject(new RestError(`Error reading response as text: ${e3.message}`, { |
| 76916 | code: RestError.PARSE_ERROR |
| 76917 | })); |
| 76918 | } |