(a: any, b: any)
| 1 | // Minimal deep equal utility for primitives, arrays, and plain objects |
| 2 | export function deepEqual(a: any, b: any): boolean { |
| 3 | if (a === b) return true; |
| 4 | if (typeof a !== typeof b) return false; |
| 5 | |
| 6 | if (Array.isArray(a) && Array.isArray(b)) { |
| 7 | if (a.length !== b.length) return false; |
| 8 | for (let i = 0; i < a.length; i++) { |
| 9 | if (!deepEqual(a[i], b[i])) return false; |
| 10 | } |
| 11 | return true; |
| 12 | } |
| 13 | |
| 14 | if (typeof a === "object" && typeof b === "object") { |
| 15 | const aKeys = Object.keys(a); |
| 16 | const bKeys = Object.keys(b); |
| 17 | if (aKeys.length !== bKeys.length) return false; |
| 18 | for (const key of aKeys) { |
| 19 | if (!(key in b)) return false; |
| 20 | |
| 21 | if (!Object.hasOwn(b, key) || !deepEqual(a[key], b[key])) return false; |
| 22 | } |
| 23 | |
| 24 | return true; |
| 25 | } |
| 26 | |
| 27 | return false; |
| 28 | } |
no outgoing calls
no test coverage detected