@whitesev/utils 1.3.7 → 1.3.8
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.amd.js +9 -1
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +9 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +9 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +9 -1
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +9 -1
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +9 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/src/Utils.d.ts +4 -2
- package/package.json +1 -1
- package/src/Utils.ts +12 -1
package/dist/src/Utils.d.ts
CHANGED
|
@@ -1806,10 +1806,12 @@ declare class Utils {
|
|
|
1806
1806
|
createUtils(option?: UtilsCoreOption): Utils;
|
|
1807
1807
|
/**
|
|
1808
1808
|
* 将对象转换为FormData
|
|
1809
|
+
* @param data 待转换的对象
|
|
1810
|
+
* @param isEncode 是否对值为string进行编码转换(encodeURIComponent)
|
|
1809
1811
|
*/
|
|
1810
1812
|
toFormData(data: {
|
|
1811
|
-
[key: string]: string | Blob | File;
|
|
1812
|
-
}): FormData;
|
|
1813
|
+
[key: string]: string | Blob | File | number;
|
|
1814
|
+
}, isEncode?: boolean): FormData;
|
|
1813
1815
|
}
|
|
1814
1816
|
declare let utils: Utils;
|
|
1815
1817
|
export { utils as Utils };
|
package/package.json
CHANGED
package/src/Utils.ts
CHANGED
|
@@ -4898,11 +4898,22 @@ class Utils {
|
|
|
4898
4898
|
|
|
4899
4899
|
/**
|
|
4900
4900
|
* 将对象转换为FormData
|
|
4901
|
+
* @param data 待转换的对象
|
|
4902
|
+
* @param isEncode 是否对值为string进行编码转换(encodeURIComponent)
|
|
4901
4903
|
*/
|
|
4902
|
-
toFormData(
|
|
4904
|
+
toFormData(
|
|
4905
|
+
data: { [key: string]: string | Blob | File | number },
|
|
4906
|
+
isEncode: boolean = false
|
|
4907
|
+
) {
|
|
4903
4908
|
const formData = new FormData();
|
|
4904
4909
|
Object.keys(data).forEach((key) => {
|
|
4905
4910
|
let value = data[key];
|
|
4911
|
+
if (typeof value === "number") {
|
|
4912
|
+
value = value.toString();
|
|
4913
|
+
}
|
|
4914
|
+
if (isEncode && typeof value === "string") {
|
|
4915
|
+
value = encodeURIComponent(value);
|
|
4916
|
+
}
|
|
4906
4917
|
if (value instanceof File) {
|
|
4907
4918
|
formData.append(key, value, value.name);
|
|
4908
4919
|
} else {
|