@vitus-labs/core 2.6.2 → 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
@@ -322,7 +323,7 @@ declare const render: Render;
322
323
  declare const useStableValue: <T>(value: T) => T;
323
324
  //#endregion
324
325
  //#region src/utils.d.ts
325
- declare const omit: <T extends Record<string, any>>(obj: T | null | undefined, keys?: readonly (string | keyof T)[]) => Partial<T>;
326
+ declare const omit: <T extends Record<string, any>>(obj: T | null | undefined, keys?: readonly (string | keyof T)[] | ReadonlySet<string | keyof T>) => Partial<T>;
326
327
  declare const pick: <T extends Record<string, any>>(obj: T | null | undefined, keys?: readonly (string | keyof T)[]) => Partial<T>;
327
328
  declare const get: (obj: any, path: string | string[], defaultValue?: any) => any;
328
329
  declare const set: (obj: Record<string, any>, path: string | string[], value: any) => Record<string, any>;
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
@@ -453,9 +460,10 @@ const render = (content, attachProps) => {
453
460
  //#region src/utils.ts
454
461
  const omit = (obj, keys) => {
455
462
  if (obj == null) return {};
456
- if (!keys || keys.length === 0) return { ...obj };
463
+ if (!keys) return { ...obj };
464
+ const keysSet = keys instanceof Set ? keys : new Set(keys);
465
+ if (keysSet.size === 0) return { ...obj };
457
466
  const result = {};
458
- const keysSet = new Set(keys);
459
467
  for (const key in obj) if (Object.hasOwn(obj, key) && !keysSet.has(key)) result[key] = obj[key];
460
468
  return result;
461
469
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitus-labs/core",
3
- "version": "2.6.2",
3
+ "version": "2.7.1",
4
4
  "license": "MIT",
5
5
  "author": "Vit Bokisch <vit@bokisch.cz>",
6
6
  "maintainers": [
@@ -59,7 +59,7 @@
59
59
  "react-is": "^19.2.4"
60
60
  },
61
61
  "devDependencies": {
62
- "@vitus-labs/tools-rolldown": "2.3.1",
63
- "@vitus-labs/tools-typescript": "2.3.1"
62
+ "@vitus-labs/tools-rolldown": "2.5.0",
63
+ "@vitus-labs/tools-typescript": "2.5.0"
64
64
  }
65
65
  }