@whitesev/utils 2.5.1 → 2.5.3

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.
@@ -82,7 +82,7 @@ declare class Utils {
82
82
  * 复制formData数据
83
83
  * @param formData 需要clone的数据
84
84
  */
85
- cloneFormData<T extends FormData>(formData: T): T;
85
+ cloneFormData<T extends FormData>(formData: T, filterFn?: (key: string, value: string | Blob) => boolean): T;
86
86
  /**
87
87
  * 函数重载实现
88
88
  * @example
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whitesev/utils",
3
- "version": "2.5.1",
3
+ "version": "2.5.3",
4
4
  "description": "一个常用的工具库",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
package/src/Utils.ts CHANGED
@@ -29,7 +29,7 @@ class Utils {
29
29
  this.windowApi = new WindowApi(option);
30
30
  }
31
31
  /** 版本号 */
32
- version = "2024.11.6";
32
+ version = "2024.11.16";
33
33
 
34
34
  /**
35
35
  * 在页面中增加style元素,如果html节点存在子节点,添加子节点第一个,反之,添加到html节点的子节点最后一个
@@ -309,10 +309,17 @@ class Utils {
309
309
  * 复制formData数据
310
310
  * @param formData 需要clone的数据
311
311
  */
312
- cloneFormData<T extends FormData>(formData: T): T;
313
- cloneFormData<T extends FormData>(formData: T) {
314
- let clonedFormData = new FormData();
312
+ cloneFormData<T extends FormData>(
313
+ formData: T,
314
+ filterFn?: (key: string, value: string | Blob) => boolean
315
+ ): T {
316
+ let clonedFormData = new FormData() as T;
315
317
  for (let [key, value] of (formData as any).entries()) {
318
+ let isFilter =
319
+ typeof filterFn === "function" ? filterFn(key, value) : false;
320
+ if (typeof isFilter === "boolean" && isFilter) {
321
+ continue;
322
+ }
316
323
  clonedFormData.append(key, value);
317
324
  }
318
325
  return clonedFormData;
@@ -1237,9 +1244,9 @@ class Utils {
1237
1244
  } {
1238
1245
  deviation = Number.isNaN(deviation) ? 1 : deviation;
1239
1246
  const UtilsContext = this;
1240
- // 最大值2147483647
1247
+ // 最大值 2147483647
1241
1248
  const maxZIndex = Math.pow(2, 31) - 1;
1242
- // 比较值2000000000
1249
+ // 比较值 2000000000
1243
1250
  const maxZIndexCompare = 2 * Math.pow(10, 9);
1244
1251
  // 当前页面最大的z-index
1245
1252
  let zIndex = 0;
@@ -1291,7 +1298,7 @@ class Utils {
1291
1298
  zIndex += deviation;
1292
1299
  if (zIndex >= maxZIndexCompare) {
1293
1300
  // 最好不要超过最大值
1294
- zIndex = maxZIndex;
1301
+ zIndex = maxZIndexCompare;
1295
1302
  }
1296
1303
  return {
1297
1304
  node: maxZIndexNode,