zek 19.0.14 → 19.0.16

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/fesm2022/zek.mjs CHANGED
@@ -1055,25 +1055,69 @@ class ObjectHelper {
1055
1055
  return target;
1056
1056
  }
1057
1057
  static deepCopy(value) {
1058
+ // 1. Guard clause: if value is null or not an object, return it.
1059
+ // (This handles primitives and breaks recursion)
1058
1060
  if (!this.isObject(value))
1059
1061
  return value;
1060
- let output = {};
1062
+ // 2. Handle Arrays
1061
1063
  if (Array.isArray(value)) {
1062
- output = value.map(x => this.deepCopy(x));
1063
- }
1064
- else {
1065
- Object.keys(value).forEach((key) => {
1066
- const v = value[key];
1067
- if (this.isObject(v)) {
1068
- output[key] = this.deepCopy(v);
1069
- }
1070
- else {
1071
- Object.assign(output, { [key]: v });
1072
- }
1073
- });
1064
+ return value.map(x => this.deepCopy(x));
1065
+ }
1066
+ // 3. Handle Objects
1067
+ const output = {};
1068
+ for (const key of Object.keys(value)) {
1069
+ const v = value[key];
1070
+ if (this.isObject(v)) {
1071
+ output[key] = this.deepCopy(v);
1072
+ }
1073
+ else {
1074
+ Object.assign(output, { [key]: v });
1075
+ }
1074
1076
  }
1075
1077
  return output;
1076
1078
  }
1079
+ static deepEquals(a, b) {
1080
+ // 1. Strict equality for primitives
1081
+ if (a === b)
1082
+ return true;
1083
+ // 2. If one is null/undefined or types differ → not equal
1084
+ if (a == null || b == null || typeof a !== typeof b)
1085
+ return false;
1086
+ // 3. Date comparison
1087
+ if (a instanceof Date && b instanceof Date) {
1088
+ return a.getTime() === b.getTime();
1089
+ }
1090
+ // 4. Arrays
1091
+ if (Array.isArray(a)) {
1092
+ if (!Array.isArray(b))
1093
+ return false;
1094
+ if (a.length !== b.length)
1095
+ return false;
1096
+ for (let i = 0; i < a.length; i++) {
1097
+ if (!this.deepEquals(a[i], b[i]))
1098
+ return false;
1099
+ }
1100
+ return true;
1101
+ }
1102
+ // 5. Objects
1103
+ if (this.isObject(a)) {
1104
+ if (!this.isObject(b))
1105
+ return false;
1106
+ const keysA = Object.keys(a);
1107
+ const keysB = Object.keys(b);
1108
+ if (keysA.length !== keysB.length)
1109
+ return false;
1110
+ for (const key of keysA) {
1111
+ if (!keysB.includes(key))
1112
+ return false;
1113
+ if (!this.deepEquals(a[key], b[key]))
1114
+ return false;
1115
+ }
1116
+ return true;
1117
+ }
1118
+ // 6. Fallback
1119
+ return false;
1120
+ }
1077
1121
  }
1078
1122
 
1079
1123
  class FilterHelper {
@@ -2837,6 +2881,12 @@ class IdName {
2837
2881
  }
2838
2882
  class IdNameChecked extends IdName {
2839
2883
  checked;
2884
+ constructor(init) {
2885
+ super();
2886
+ if (init) {
2887
+ Object.assign(this, init);
2888
+ }
2889
+ }
2840
2890
  }
2841
2891
 
2842
2892
  class KeyPair {