@acrool/react-fetcher 0.0.10-alpha.1 → 0.0.10
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.
|
@@ -108,25 +108,36 @@ var ERequestMethod = /* @__PURE__ */ ((ERequestMethod2) => {
|
|
|
108
108
|
ERequestMethod2["PATCH"] = "PATCH";
|
|
109
109
|
return ERequestMethod2;
|
|
110
110
|
})(ERequestMethod || {});
|
|
111
|
-
function
|
|
112
|
-
const n = new FormData(), e2 = (s2,
|
|
113
|
-
for (const [a2,
|
|
114
|
-
const
|
|
115
|
-
if (
|
|
116
|
-
n.append(
|
|
117
|
-
else if (
|
|
118
|
-
const
|
|
119
|
-
n.append(
|
|
120
|
-
} else Array.isArray(
|
|
121
|
-
typeof
|
|
122
|
-
}) : typeof
|
|
111
|
+
function m(r2) {
|
|
112
|
+
const n = new FormData(), e2 = (s2, o = "") => {
|
|
113
|
+
for (const [a2, t2] of Object.entries(s2)) {
|
|
114
|
+
const c = o ? `${o}[${a2}]` : a2;
|
|
115
|
+
if (t2 instanceof File)
|
|
116
|
+
n.append(c, t2);
|
|
117
|
+
else if (t2 instanceof Blob) {
|
|
118
|
+
const i2 = t2.type.split("/")[1] || "bin", f = `${a2}.${i2}`;
|
|
119
|
+
n.append(c, t2, f);
|
|
120
|
+
} else Array.isArray(t2) ? t2.forEach((l2, i2) => {
|
|
121
|
+
typeof l2 == "object" && l2 !== null ? e2(l2, `${c}[${i2}]`) : n.append(`${c}[${i2}]`, l2);
|
|
122
|
+
}) : typeof t2 == "object" && t2 !== null ? e2(t2, c) : t2 != null && n.append(c, t2);
|
|
123
123
|
}
|
|
124
124
|
};
|
|
125
|
-
return e2(
|
|
125
|
+
return e2(r2), n;
|
|
126
|
+
}
|
|
127
|
+
function A(r2) {
|
|
128
|
+
const n = new URLSearchParams(), e2 = (s2, o = "") => {
|
|
129
|
+
for (const [a2, t2] of Object.entries(s2)) {
|
|
130
|
+
const c = o ? `${o}[${a2}]` : a2;
|
|
131
|
+
Array.isArray(t2) ? t2.forEach((l2, i2) => {
|
|
132
|
+
typeof l2 == "object" && l2 !== null ? e2(l2, `${c}[${i2}]`) : n.append(`${c}[${i2}]`, String(l2));
|
|
133
|
+
}) : typeof t2 == "object" && t2 !== null ? e2(t2, c) : t2 != null && n.append(c, String(t2));
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
return e2(r2), n;
|
|
126
137
|
}
|
|
127
138
|
const getDataWithContentType = (contentType, data = {}) => {
|
|
128
|
-
if (
|
|
129
|
-
if (contentType === ERequestContentType.formUrlDecode) return data;
|
|
139
|
+
if (contentType === ERequestContentType.formData) return m(data);
|
|
140
|
+
if (contentType === ERequestContentType.formUrlDecode) return A(data);
|
|
130
141
|
return JSON.stringify(data);
|
|
131
142
|
};
|
|
132
143
|
const createRestFulFetcher = (axiosInstance, document2, options) => {
|
|
@@ -761,7 +772,7 @@ const isHTMLForm = kindOfTest("HTMLFormElement");
|
|
|
761
772
|
const toCamelCase = (str) => {
|
|
762
773
|
return str.toLowerCase().replace(
|
|
763
774
|
/[-_\s]([a-z\d])(\w*)/g,
|
|
764
|
-
function replacer(
|
|
775
|
+
function replacer(m2, p1, p2) {
|
|
765
776
|
return p1.toUpperCase() + p2;
|
|
766
777
|
}
|
|
767
778
|
);
|