@vitus-labs/core 2.7.0 → 2.7.1

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/lib/index.d.ts CHANGED
@@ -289,8 +289,9 @@ declare const isEmpty: IsEmpty;
289
289
  //#region src/isEqual.d.ts
290
290
  /**
291
291
  * Order-independent deep equality for plain objects, arrays, and primitives.
292
- * Handles null, undefined, nested structures. Does not handle Date, RegExp,
293
- * Map, Set, or circular references — not needed for theme/props comparison.
292
+ * Handles null, undefined, nested structures, and circular references via
293
+ * cycle detection. Does not handle Date, RegExp, Map, Set — not needed for
294
+ * theme/props comparison.
294
295
  */
295
296
  declare const isEqual: (a: unknown, b: unknown) => boolean;
296
297
  //#endregion
package/lib/index.js CHANGED
@@ -143,32 +143,39 @@ const isEmpty = (param) => {
143
143
 
144
144
  //#endregion
145
145
  //#region src/isEqual.ts
146
- /**
147
- * Order-independent deep equality for plain objects, arrays, and primitives.
148
- * Handles null, undefined, nested structures. Does not handle Date, RegExp,
149
- * Map, Set, or circular references — not needed for theme/props comparison.
150
- */
151
- const isArrayEqual = (a, b) => {
146
+ const isArrayEqual = (a, b, seen) => {
152
147
  if (a.length !== b.length) return false;
153
- for (let i = 0; i < a.length; i++) if (!isEqual(a[i], b[i])) return false;
148
+ for (let i = 0; i < a.length; i++) if (!isEqualInner(a[i], b[i], seen)) return false;
154
149
  return true;
155
150
  };
156
- const isObjectEqual = (a, b) => {
151
+ const isObjectEqual = (a, b, seen) => {
157
152
  const aKeys = Object.keys(a);
158
153
  if (aKeys.length !== Object.keys(b).length) return false;
159
154
  for (const key of aKeys) {
160
155
  if (!Object.hasOwn(b, key)) return false;
161
- if (!isEqual(a[key], b[key])) return false;
156
+ if (!isEqualInner(a[key], b[key], seen)) return false;
162
157
  }
163
158
  return true;
164
159
  };
165
- const isEqual = (a, b) => {
160
+ const isEqualInner = (a, b, seen) => {
166
161
  if (Object.is(a, b)) return true;
167
162
  if (typeof a !== typeof b || a == null || b == null || typeof a !== "object") return false;
168
- if (Array.isArray(a)) return Array.isArray(b) && isArrayEqual(a, b);
163
+ const aObj = a;
164
+ const bObj = b;
165
+ let bSet = seen.get(aObj);
166
+ if (bSet !== void 0) {
167
+ if (bSet.has(bObj)) return true;
168
+ bSet.add(bObj);
169
+ } else {
170
+ bSet = /* @__PURE__ */ new WeakSet();
171
+ bSet.add(bObj);
172
+ seen.set(aObj, bSet);
173
+ }
174
+ if (Array.isArray(a)) return Array.isArray(b) && isArrayEqual(a, b, seen);
169
175
  if (Array.isArray(b)) return false;
170
- return isObjectEqual(a, b);
176
+ return isObjectEqual(a, b, seen);
171
177
  };
178
+ const isEqual = (a, b) => isEqualInner(a, b, /* @__PURE__ */ new WeakMap());
172
179
 
173
180
  //#endregion
174
181
  //#region src/useStableValue.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitus-labs/core",
3
- "version": "2.7.0",
3
+ "version": "2.7.1",
4
4
  "license": "MIT",
5
5
  "author": "Vit Bokisch <vit@bokisch.cz>",
6
6
  "maintainers": [