MCPcopy Create free account
hub / github.com/dmno-dev/bumpy / deepEqual

Function deepEqual

packages/bumpy/src/commands/check.ts:393–407  ·  view source on GitHub ↗

Structural equality for parsed JSON values (objects compared key-insensitive to order).

(a: unknown, b: unknown)

Source from the content-addressed store, hash-verified

391
392/** Structural equality for parsed JSON values (objects compared key-insensitive to order). */
393function deepEqual(a: unknown, b: unknown): boolean {
394 if (a === b) return true;
395 if (typeof a !== typeof b || a === null || b === null) return false;
396 if (typeof a !== 'object') return false;
397 if (Array.isArray(a) || Array.isArray(b)) {
398 if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return false;
399 return a.every((v, i) => deepEqual(v, b[i]));
400 }
401 const ao = a as Record<string, unknown>;
402 const bo = b as Record<string, unknown>;
403 const ak = Object.keys(ao);
404 const bk = Object.keys(bo);
405 if (ak.length !== bk.length) return false;
406 return ak.every((k) => Object.prototype.hasOwnProperty.call(bo, k) && deepEqual(ao[k], bo[k]));
407}
408
409/**
410 * Compute which catalog entries changed between the base ref and HEAD.

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…