@whitesev/utils 1.3.7 → 1.3.9

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.
@@ -5954,6 +5954,9 @@ System.register('Utils', [], (function (exports) {
5954
5954
  if (typeof checkObj === "function") {
5955
5955
  obj = checkObj();
5956
5956
  }
5957
+ if (typeof obj !== "object") {
5958
+ return;
5959
+ }
5957
5960
  if ((typeof checkPropertyName === "function" && checkPropertyName(obj)) ||
5958
5961
  Reflect.has(obj, checkPropertyName)) {
5959
5962
  isResolve = true;
@@ -6064,11 +6067,19 @@ System.register('Utils', [], (function (exports) {
6064
6067
  }
6065
6068
  /**
6066
6069
  * 将对象转换为FormData
6070
+ * @param data 待转换的对象
6071
+ * @param isEncode 是否对值为string进行编码转换(encodeURIComponent)
6067
6072
  */
6068
- toFormData(data) {
6073
+ toFormData(data, isEncode = false) {
6069
6074
  const formData = new FormData();
6070
6075
  Object.keys(data).forEach((key) => {
6071
6076
  let value = data[key];
6077
+ if (typeof value === "number") {
6078
+ value = value.toString();
6079
+ }
6080
+ if (isEncode && typeof value === "string") {
6081
+ value = encodeURIComponent(value);
6082
+ }
6072
6083
  if (value instanceof File) {
6073
6084
  formData.append(key, value, value.name);
6074
6085
  }