sculp-js 1.8.2 → 1.8.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.
Files changed (63) hide show
  1. package/lib/cjs/array.js +2 -3
  2. package/lib/cjs/async.js +1 -1
  3. package/lib/cjs/base64.js +1 -1
  4. package/lib/cjs/clipboard.js +1 -1
  5. package/lib/cjs/cloneDeep.js +117 -0
  6. package/lib/cjs/cookie.js +1 -1
  7. package/lib/cjs/date.js +1 -1
  8. package/lib/cjs/dom.js +1 -1
  9. package/lib/cjs/download.js +1 -1
  10. package/lib/cjs/easing.js +1 -1
  11. package/lib/cjs/file.js +1 -1
  12. package/lib/cjs/func.js +1 -28
  13. package/lib/cjs/index.js +5 -3
  14. package/lib/cjs/isEqual.js +133 -0
  15. package/lib/cjs/math.js +1 -1
  16. package/lib/cjs/number.js +1 -1
  17. package/lib/cjs/object.js +1 -235
  18. package/lib/cjs/path.js +1 -1
  19. package/lib/cjs/qs.js +1 -1
  20. package/lib/cjs/random.js +1 -1
  21. package/lib/cjs/string.js +1 -1
  22. package/lib/cjs/tooltip.js +1 -1
  23. package/lib/cjs/tree.js +1 -1
  24. package/lib/cjs/type.js +1 -1
  25. package/lib/cjs/unique.js +1 -1
  26. package/lib/cjs/url.js +1 -1
  27. package/lib/cjs/validator.js +1 -1
  28. package/lib/cjs/variable.js +1 -1
  29. package/lib/cjs/watermark.js +1 -1
  30. package/lib/cjs/we-decode.js +1 -1
  31. package/lib/es/array.js +2 -3
  32. package/lib/es/async.js +1 -1
  33. package/lib/es/base64.js +1 -1
  34. package/lib/es/clipboard.js +1 -1
  35. package/lib/es/cloneDeep.js +115 -0
  36. package/lib/es/cookie.js +1 -1
  37. package/lib/es/date.js +1 -1
  38. package/lib/es/dom.js +1 -1
  39. package/lib/es/download.js +1 -1
  40. package/lib/es/easing.js +1 -1
  41. package/lib/es/file.js +1 -1
  42. package/lib/es/func.js +1 -28
  43. package/lib/es/index.js +4 -2
  44. package/lib/es/isEqual.js +131 -0
  45. package/lib/es/math.js +1 -1
  46. package/lib/es/number.js +1 -1
  47. package/lib/es/object.js +2 -234
  48. package/lib/es/path.js +1 -1
  49. package/lib/es/qs.js +1 -1
  50. package/lib/es/random.js +1 -1
  51. package/lib/es/string.js +1 -1
  52. package/lib/es/tooltip.js +1 -1
  53. package/lib/es/tree.js +1 -1
  54. package/lib/es/type.js +1 -1
  55. package/lib/es/unique.js +1 -1
  56. package/lib/es/url.js +1 -1
  57. package/lib/es/validator.js +1 -1
  58. package/lib/es/variable.js +1 -1
  59. package/lib/es/watermark.js +1 -1
  60. package/lib/es/we-decode.js +1 -1
  61. package/lib/index.d.ts +21 -19
  62. package/lib/umd/index.js +232 -262
  63. package/package.json +1 -1
package/lib/umd/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sculp-js v1.8.1
2
+ * sculp-js v1.8.3
3
3
  * (c) 2023-present chandq
4
4
  * Released under the MIT License.
5
5
  */
@@ -72,7 +72,6 @@
72
72
  function arrayInsertBefore(array, start, to) {
73
73
  if (start === to || start + 1 === to)
74
74
  return;
75
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
76
75
  const [source] = array.splice(start, 1);
77
76
  const insertIndex = to < start ? to : to - 1;
78
77
  array.splice(insertIndex, 0, source);
@@ -92,7 +91,7 @@
92
91
  if (_expect(val, idx))
93
92
  indexes.push(idx);
94
93
  });
95
- arrayEach(indexes, (val, idx) => {
94
+ indexes.forEach((val, idx) => {
96
95
  array.splice(val - idx, 1);
97
96
  });
98
97
  return array;
@@ -294,7 +293,6 @@
294
293
  for (const key in obj) {
295
294
  if (!objectHas(obj, key))
296
295
  continue;
297
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
298
296
  obj2[key] = iterator(obj[key], key);
299
297
  }
300
298
  return obj2;
@@ -309,7 +307,6 @@
309
307
  const obj2 = {};
310
308
  objectEach(obj, (v, k) => {
311
309
  if (keys.includes(k)) {
312
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
313
310
  // @ts-ignore
314
311
  obj2[k] = v;
315
312
  }
@@ -326,7 +323,6 @@
326
323
  const obj2 = {};
327
324
  objectEach(obj, (v, k) => {
328
325
  if (!keys.includes(k)) {
329
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
330
326
  // @ts-ignore
331
327
  obj2[k] = v;
332
328
  }
@@ -379,7 +375,6 @@
379
375
  const map = new Map();
380
376
  for (let i = 0, len = targets.length; i < len; i++) {
381
377
  const target = targets[i];
382
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
383
378
  // @ts-ignore
384
379
  source = merge(map, source, target);
385
380
  }
@@ -437,234 +432,6 @@
437
432
  v: tempObj ? tempObj[keyArr[i]] : undefined
438
433
  };
439
434
  }
440
- /**
441
- * 深拷贝堪称完全体 即:任何类型的数据都会被深拷贝
442
- *
443
- * 包含对null、原始值、对象循环引用的处理
444
- *
445
- * 对Map、Set、ArrayBuffer、Date、RegExp、Array、Object及原型链属性方法执行深拷贝
446
- * @param {T} source
447
- * @param {WeakMap} map
448
- * @returns {T}
449
- */
450
- function cloneDeep(source, map = new WeakMap()) {
451
- // 处理原始类型和 null/undefined
452
- if (source === null || typeof source !== 'object') {
453
- return source;
454
- }
455
- // 处理循环引用
456
- if (map.has(source)) {
457
- return map.get(source);
458
- }
459
- // 处理 ArrayBuffer
460
- if (source instanceof ArrayBuffer) {
461
- const copy = new ArrayBuffer(source.byteLength);
462
- new Uint8Array(copy).set(new Uint8Array(source));
463
- map.set(source, copy);
464
- return copy;
465
- }
466
- // 处理 DataView 和 TypedArray (Uint8Array 等)
467
- if (ArrayBuffer.isView(source)) {
468
- const constructor = source.constructor;
469
- const bufferCopy = cloneDeep(source.buffer, map);
470
- return new constructor(bufferCopy, source.byteOffset, source.length);
471
- }
472
- // 处理 Date 对象
473
- if (source instanceof Date) {
474
- const copy = new Date(source.getTime());
475
- map.set(source, copy);
476
- return copy;
477
- }
478
- // 处理 RegExp 对象
479
- if (source instanceof RegExp) {
480
- const copy = new RegExp(source.source, source.flags);
481
- copy.lastIndex = source.lastIndex; // 保留匹配状态
482
- map.set(source, copy);
483
- return copy;
484
- }
485
- // 处理 Map
486
- if (source instanceof Map) {
487
- const copy = new Map();
488
- map.set(source, copy);
489
- source.forEach((value, key) => {
490
- copy.set(cloneDeep(key, map), cloneDeep(value, map));
491
- });
492
- return copy;
493
- }
494
- // 处理 Set
495
- if (source instanceof Set) {
496
- const copy = new Set();
497
- map.set(source, copy);
498
- source.forEach(value => {
499
- copy.add(cloneDeep(value, map));
500
- });
501
- return copy;
502
- }
503
- // 处理数组 (包含稀疏数组)
504
- if (Array.isArray(source)) {
505
- const copy = new Array(source.length);
506
- map.set(source, copy);
507
- // 克隆所有有效索引
508
- for (let i = 0, len = source.length; i < len; i++) {
509
- if (i in source) {
510
- // 保留空位
511
- copy[i] = cloneDeep(source[i], map);
512
- }
513
- }
514
- // 克隆数组的自定义属性
515
- const descriptors = Object.getOwnPropertyDescriptors(source);
516
- for (const key of Reflect.ownKeys(descriptors)) {
517
- Object.defineProperty(copy, key, {
518
- ...descriptors[key],
519
- value: cloneDeep(descriptors[key].value, map)
520
- });
521
- }
522
- return copy;
523
- }
524
- // 处理普通对象和类实例
525
- const copy = Object.create(Object.getPrototypeOf(source));
526
- map.set(source, copy);
527
- const descriptors = Object.getOwnPropertyDescriptors(source);
528
- for (const key of Reflect.ownKeys(descriptors)) {
529
- const descriptor = descriptors[key];
530
- if ('value' in descriptor) {
531
- // 克隆数据属性
532
- descriptor.value = cloneDeep(descriptor.value, map);
533
- }
534
- else {
535
- // 处理访问器属性 (getter/setter)
536
- if (descriptor.get) {
537
- descriptor.get = cloneDeep(descriptor.get, map);
538
- }
539
- if (descriptor.set) {
540
- descriptor.set = cloneDeep(descriptor.set, map);
541
- }
542
- }
543
- Object.defineProperty(copy, key, descriptor);
544
- }
545
- return copy;
546
- }
547
- /**
548
- * 比较两值是否相等,适用所有数据类型
549
- * @param {Comparable} a
550
- * @param {Comparable} b
551
- * @returns {boolean}
552
- */
553
- function isEqual(a, b) {
554
- return deepEqual(a, b);
555
- }
556
- function deepEqual(a, b, compared = new WeakMap()) {
557
- // 相同值快速返回
558
- if (Object.is(a, b))
559
- return true;
560
- // 类型不同直接返回false
561
- const typeA = Object.prototype.toString.call(a);
562
- const typeB = Object.prototype.toString.call(b);
563
- if (typeA !== typeB)
564
- return false;
565
- // 只缓存对象类型
566
- if (isObject(a) && isObject(b)) {
567
- if (compared.has(a))
568
- return compared.get(a) === b;
569
- compared.set(a, b);
570
- compared.set(b, a);
571
- }
572
- // 处理特殊对象类型
573
- switch (typeA) {
574
- case '[object Date]':
575
- return a.getTime() === b.getTime();
576
- case '[object RegExp]':
577
- return a.toString() === b.toString();
578
- case '[object Map]':
579
- return compareMap(a, b, compared);
580
- case '[object Set]':
581
- return compareSet(a, b, compared);
582
- case '[object ArrayBuffer]':
583
- return compareArrayBuffer(a, b);
584
- case '[object DataView]':
585
- return compareDataView(a, b, compared);
586
- case '[object Int8Array]':
587
- case '[object Uint8Array]':
588
- case '[object Uint8ClampedArray]':
589
- case '[object Int16Array]':
590
- case '[object Uint16Array]':
591
- case '[object Int32Array]':
592
- case '[object Uint32Array]':
593
- case '[object Float32Array]':
594
- case '[object Float64Array]':
595
- return compareTypedArray(a, b, compared);
596
- case '[object Object]':
597
- return compareObjects(a, b, compared);
598
- case '[object Array]':
599
- return compareArrays(a, b, compared);
600
- }
601
- return false;
602
- }
603
- // 辅助比较函数
604
- function compareMap(a, b, compared) {
605
- if (a.size !== b.size)
606
- return false;
607
- for (const [key, value] of a) {
608
- if (!b.has(key) || !deepEqual(value, b.get(key), compared))
609
- return false;
610
- }
611
- return true;
612
- }
613
- function compareSet(a, b, compared) {
614
- if (a.size !== b.size)
615
- return false;
616
- for (const value of a) {
617
- let found = false;
618
- for (const bValue of b) {
619
- if (deepEqual(value, bValue, compared)) {
620
- found = true;
621
- break;
622
- }
623
- }
624
- if (!found)
625
- return false;
626
- }
627
- return true;
628
- }
629
- function compareArrayBuffer(a, b) {
630
- if (a.byteLength !== b.byteLength)
631
- return false;
632
- return new DataView(a).getInt32(0) === new DataView(b).getInt32(0);
633
- }
634
- function compareDataView(a, b, compared) {
635
- return a.byteLength === b.byteLength && deepEqual(new Uint8Array(a.buffer), new Uint8Array(b.buffer), compared);
636
- }
637
- function compareTypedArray(a, b, compared) {
638
- return a.byteLength === b.byteLength && deepEqual(Array.from(a), Array.from(b), compared);
639
- }
640
- function compareObjects(a, b, compared) {
641
- const keysA = Reflect.ownKeys(a);
642
- const keysB = Reflect.ownKeys(b);
643
- if (keysA.length !== keysB.length)
644
- return false;
645
- for (const key of keysA) {
646
- if (!keysB.includes(key))
647
- return false;
648
- if (!deepEqual(a[key], b[key], compared))
649
- return false;
650
- }
651
- // 原型链比较
652
- return Object.getPrototypeOf(a) === Object.getPrototypeOf(b);
653
- }
654
- function compareArrays(a, b, compared) {
655
- // 增加有效索引检查
656
- const keysA = Object.keys(a).map(Number);
657
- const keysB = Object.keys(b).map(Number);
658
- if (keysA.length !== keysB.length)
659
- return false;
660
- // 递归比较每个元素
661
- for (let i = 0, len = a.length; i < len; i++) {
662
- if (!deepEqual(a[i], b[i], compared))
663
- return false;
664
- }
665
- // 比较数组对象的其他属性
666
- return compareObjects(a, b, compared);
667
- }
668
435
 
669
436
  /**
670
437
  * 将字符串转换为驼峰格式
@@ -1958,13 +1725,10 @@
1958
1725
  let called = false;
1959
1726
  let result;
1960
1727
  return function (...args) {
1961
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
1962
1728
  if (called)
1963
1729
  return result;
1964
1730
  called = true;
1965
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
1966
1731
  result = func.call(this, ...args);
1967
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
1968
1732
  return result;
1969
1733
  };
1970
1734
  };
@@ -1974,24 +1738,12 @@
1974
1738
  * @param val
1975
1739
  */
1976
1740
  function setGlobal(key, val) {
1977
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1978
- // @ts-ignore
1979
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
1980
1741
  if (typeof globalThis !== 'undefined')
1981
1742
  globalThis[key] = val;
1982
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1983
- // @ts-ignore
1984
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
1985
1743
  else if (typeof window !== 'undefined')
1986
1744
  window[key] = val;
1987
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1988
- // @ts-ignore
1989
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
1990
1745
  else if (typeof global !== 'undefined')
1991
1746
  global[key] = val;
1992
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1993
- // @ts-ignore
1994
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
1995
1747
  else if (typeof self !== 'undefined')
1996
1748
  self[key] = val;
1997
1749
  else
@@ -2003,24 +1755,12 @@
2003
1755
  * @param val
2004
1756
  */
2005
1757
  function getGlobal(key) {
2006
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2007
- // @ts-ignore
2008
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
2009
1758
  if (typeof globalThis !== 'undefined')
2010
1759
  return globalThis[key];
2011
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2012
- // @ts-ignore
2013
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
2014
1760
  else if (typeof window !== 'undefined')
2015
1761
  return window[key];
2016
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2017
- // @ts-ignore
2018
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
2019
1762
  else if (typeof global !== 'undefined')
2020
1763
  return global[key];
2021
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2022
- // @ts-ignore
2023
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
2024
1764
  else if (typeof self !== 'undefined')
2025
1765
  return self[key];
2026
1766
  }
@@ -2951,6 +2691,236 @@
2951
2691
  }
2952
2692
  }
2953
2693
 
2694
+ /**
2695
+ * 深拷贝堪称完全体 即:任何类型的数据都会被深拷贝
2696
+ *
2697
+ * 包含对null、原始值、对象循环引用的处理
2698
+ *
2699
+ * 对Map、Set、ArrayBuffer、Date、RegExp、Array、Object及原型链属性方法执行深拷贝
2700
+ * @param {T} source
2701
+ * @param {WeakMap} map
2702
+ * @returns {T}
2703
+ */
2704
+ function cloneDeep(source, map = new WeakMap()) {
2705
+ // 处理原始类型和 null/undefined
2706
+ if (source === null || typeof source !== 'object') {
2707
+ return source;
2708
+ }
2709
+ // 处理循环引用
2710
+ if (map.has(source)) {
2711
+ return map.get(source);
2712
+ }
2713
+ // 处理 ArrayBuffer
2714
+ if (source instanceof ArrayBuffer) {
2715
+ const copy = new ArrayBuffer(source.byteLength);
2716
+ new Uint8Array(copy).set(new Uint8Array(source));
2717
+ map.set(source, copy);
2718
+ return copy;
2719
+ }
2720
+ // 处理 DataView 和 TypedArray (Uint8Array 等)
2721
+ if (ArrayBuffer.isView(source)) {
2722
+ const constructor = source.constructor;
2723
+ const bufferCopy = cloneDeep(source.buffer, map);
2724
+ return new constructor(bufferCopy, source.byteOffset, source.length);
2725
+ }
2726
+ // 处理 Date 对象
2727
+ if (source instanceof Date) {
2728
+ const copy = new Date(source.getTime());
2729
+ map.set(source, copy);
2730
+ return copy;
2731
+ }
2732
+ // 处理 RegExp 对象
2733
+ if (source instanceof RegExp) {
2734
+ const copy = new RegExp(source.source, source.flags);
2735
+ copy.lastIndex = source.lastIndex; // 保留匹配状态
2736
+ map.set(source, copy);
2737
+ return copy;
2738
+ }
2739
+ // 处理 Map
2740
+ if (source instanceof Map) {
2741
+ const copy = new Map();
2742
+ map.set(source, copy);
2743
+ source.forEach((value, key) => {
2744
+ copy.set(cloneDeep(key, map), cloneDeep(value, map));
2745
+ });
2746
+ return copy;
2747
+ }
2748
+ // 处理 Set
2749
+ if (source instanceof Set) {
2750
+ const copy = new Set();
2751
+ map.set(source, copy);
2752
+ source.forEach(value => {
2753
+ copy.add(cloneDeep(value, map));
2754
+ });
2755
+ return copy;
2756
+ }
2757
+ // 处理数组 (包含稀疏数组)
2758
+ if (Array.isArray(source)) {
2759
+ const copy = new Array(source.length);
2760
+ map.set(source, copy);
2761
+ // 克隆所有有效索引
2762
+ for (let i = 0, len = source.length; i < len; i++) {
2763
+ if (i in source) {
2764
+ // 保留空位
2765
+ copy[i] = cloneDeep(source[i], map);
2766
+ }
2767
+ }
2768
+ // 克隆数组的自定义属性
2769
+ const descriptors = Object.getOwnPropertyDescriptors(source);
2770
+ for (const key of Reflect.ownKeys(descriptors)) {
2771
+ Object.defineProperty(copy, key, {
2772
+ ...descriptors[key],
2773
+ value: cloneDeep(descriptors[key].value, map)
2774
+ });
2775
+ }
2776
+ return copy;
2777
+ }
2778
+ // 处理普通对象和类实例
2779
+ const copy = Object.create(Object.getPrototypeOf(source));
2780
+ map.set(source, copy);
2781
+ const descriptors = Object.getOwnPropertyDescriptors(source);
2782
+ for (const key of Reflect.ownKeys(descriptors)) {
2783
+ const descriptor = descriptors[key];
2784
+ if ('value' in descriptor) {
2785
+ // 克隆数据属性
2786
+ descriptor.value = cloneDeep(descriptor.value, map);
2787
+ }
2788
+ else {
2789
+ // 处理访问器属性 (getter/setter)
2790
+ if (descriptor.get) {
2791
+ descriptor.get = cloneDeep(descriptor.get, map);
2792
+ }
2793
+ if (descriptor.set) {
2794
+ descriptor.set = cloneDeep(descriptor.set, map);
2795
+ }
2796
+ }
2797
+ Object.defineProperty(copy, key, descriptor);
2798
+ }
2799
+ return copy;
2800
+ }
2801
+
2802
+ /**
2803
+ * 比较两值是否相等,适用所有数据类型
2804
+ * @param {Comparable} a
2805
+ * @param {Comparable} b
2806
+ * @returns {boolean}
2807
+ */
2808
+ function isEqual(a, b) {
2809
+ return deepEqual(a, b);
2810
+ }
2811
+ function deepEqual(a, b, compared = new WeakMap()) {
2812
+ // 相同值快速返回
2813
+ if (Object.is(a, b))
2814
+ return true;
2815
+ // 类型不同直接返回false
2816
+ const typeA = Object.prototype.toString.call(a);
2817
+ const typeB = Object.prototype.toString.call(b);
2818
+ if (typeA !== typeB)
2819
+ return false;
2820
+ // 只缓存对象类型
2821
+ if (isObject(a) && isObject(b)) {
2822
+ if (compared.has(a))
2823
+ return compared.get(a) === b;
2824
+ compared.set(a, b);
2825
+ compared.set(b, a);
2826
+ }
2827
+ // 处理特殊对象类型
2828
+ switch (typeA) {
2829
+ case '[object Date]':
2830
+ return a.getTime() === b.getTime();
2831
+ case '[object RegExp]':
2832
+ return a.toString() === b.toString();
2833
+ case '[object Map]':
2834
+ return compareMap(a, b, compared);
2835
+ case '[object Set]':
2836
+ return compareSet(a, b, compared);
2837
+ case '[object ArrayBuffer]':
2838
+ return compareArrayBuffer(a, b);
2839
+ case '[object DataView]':
2840
+ return compareDataView(a, b, compared);
2841
+ case '[object Int8Array]':
2842
+ case '[object Uint8Array]':
2843
+ case '[object Uint8ClampedArray]':
2844
+ case '[object Int16Array]':
2845
+ case '[object Uint16Array]':
2846
+ case '[object Int32Array]':
2847
+ case '[object Uint32Array]':
2848
+ case '[object Float32Array]':
2849
+ case '[object Float64Array]':
2850
+ return compareTypedArray(a, b, compared);
2851
+ case '[object Object]':
2852
+ return compareObjects(a, b, compared);
2853
+ case '[object Array]':
2854
+ return compareArrays(a, b, compared);
2855
+ }
2856
+ return false;
2857
+ }
2858
+ // 辅助比较函数
2859
+ function compareMap(a, b, compared) {
2860
+ if (a.size !== b.size)
2861
+ return false;
2862
+ for (const [key, value] of a) {
2863
+ if (!b.has(key) || !deepEqual(value, b.get(key), compared))
2864
+ return false;
2865
+ }
2866
+ return true;
2867
+ }
2868
+ function compareSet(a, b, compared) {
2869
+ if (a.size !== b.size)
2870
+ return false;
2871
+ for (const value of a) {
2872
+ let found = false;
2873
+ for (const bValue of b) {
2874
+ if (deepEqual(value, bValue, compared)) {
2875
+ found = true;
2876
+ break;
2877
+ }
2878
+ }
2879
+ if (!found)
2880
+ return false;
2881
+ }
2882
+ return true;
2883
+ }
2884
+ function compareArrayBuffer(a, b) {
2885
+ if (a.byteLength !== b.byteLength)
2886
+ return false;
2887
+ return new DataView(a).getInt32(0) === new DataView(b).getInt32(0);
2888
+ }
2889
+ function compareDataView(a, b, compared) {
2890
+ return a.byteLength === b.byteLength && deepEqual(new Uint8Array(a.buffer), new Uint8Array(b.buffer), compared);
2891
+ }
2892
+ function compareTypedArray(a, b, compared) {
2893
+ return a.byteLength === b.byteLength && deepEqual(Array.from(a), Array.from(b), compared);
2894
+ }
2895
+ function compareObjects(a, b, compared) {
2896
+ const keysA = Reflect.ownKeys(a);
2897
+ const keysB = Reflect.ownKeys(b);
2898
+ if (keysA.length !== keysB.length)
2899
+ return false;
2900
+ for (const key of keysA) {
2901
+ if (!keysB.includes(key))
2902
+ return false;
2903
+ if (!deepEqual(a[key], b[key], compared))
2904
+ return false;
2905
+ }
2906
+ // 原型链比较
2907
+ return Object.getPrototypeOf(a) === Object.getPrototypeOf(b);
2908
+ }
2909
+ function compareArrays(a, b, compared) {
2910
+ // 增加有效索引检查
2911
+ const keysA = Object.keys(a).map(Number);
2912
+ const keysB = Object.keys(b).map(Number);
2913
+ if (keysA.length !== keysB.length)
2914
+ return false;
2915
+ // 递归比较每个元素
2916
+ for (let i = 0, len = a.length; i < len; i++) {
2917
+ if (!deepEqual(a[i], b[i], compared))
2918
+ return false;
2919
+ }
2920
+ // 比较数组对象的其他属性
2921
+ return compareObjects(a, b, compared);
2922
+ }
2923
+
2954
2924
  exports.EMAIL_REGEX = EMAIL_REGEX;
2955
2925
  exports.HEX_POOL = HEX_POOL;
2956
2926
  exports.HTTP_URL_REGEX = HTTP_URL_REGEX;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sculp-js",
3
- "version": "1.8.2",
3
+ "version": "1.8.3",
4
4
  "packageManager": "npm@8.19.2",
5
5
  "description": "js utils library, includes function library、class library",
6
6
  "scripts": {