@ztimson/utils 0.23.11 → 0.23.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +20 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +20 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1040,6 +1040,20 @@ ${opts.message || this.desc}`;
|
|
|
1040
1040
|
return new CustomError(message, code);
|
|
1041
1041
|
}
|
|
1042
1042
|
}
|
|
1043
|
+
class HttpResponse extends Response {
|
|
1044
|
+
constructor(resp, stream) {
|
|
1045
|
+
super(stream, { headers: resp.headers, status: resp.status, statusText: resp.statusText });
|
|
1046
|
+
__publicField(this, "data");
|
|
1047
|
+
__publicField(this, "ok");
|
|
1048
|
+
__publicField(this, "redirected");
|
|
1049
|
+
__publicField(this, "type");
|
|
1050
|
+
__publicField(this, "url");
|
|
1051
|
+
this.ok = resp.ok;
|
|
1052
|
+
this.redirected = resp.redirected;
|
|
1053
|
+
this.type = resp.type;
|
|
1054
|
+
this.url = resp.url;
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1043
1057
|
const _Http = class _Http {
|
|
1044
1058
|
constructor(defaults = {}) {
|
|
1045
1059
|
__publicField(this, "interceptors", {});
|
|
@@ -1111,13 +1125,13 @@ ${opts.message || this.desc}`;
|
|
|
1111
1125
|
push();
|
|
1112
1126
|
}
|
|
1113
1127
|
});
|
|
1114
|
-
resp
|
|
1115
|
-
if (opts.decode
|
|
1128
|
+
resp = new HttpResponse(resp, stream);
|
|
1129
|
+
if (opts.decode !== false) {
|
|
1116
1130
|
const content = (_b = resp.headers.get("Content-Type")) == null ? void 0 : _b.toLowerCase();
|
|
1117
|
-
if (content == null ? void 0 : content.includes("form")) resp.data = await resp.
|
|
1118
|
-
else if (content == null ? void 0 : content.includes("json")) resp.data = await resp.
|
|
1119
|
-
else if (content == null ? void 0 : content.includes("text")) resp.data = await resp.
|
|
1120
|
-
else if (content == null ? void 0 : content.includes("application")) resp.data = await resp.
|
|
1131
|
+
if (content == null ? void 0 : content.includes("form")) resp.data = await resp.formData();
|
|
1132
|
+
else if (content == null ? void 0 : content.includes("json")) resp.data = await resp.json();
|
|
1133
|
+
else if (content == null ? void 0 : content.includes("text")) resp.data = await resp.text();
|
|
1134
|
+
else if (content == null ? void 0 : content.includes("application")) resp.data = await resp.blob();
|
|
1121
1135
|
}
|
|
1122
1136
|
if (resp.ok) res(resp);
|
|
1123
1137
|
else rej(resp);
|