UNPKG

@mastra/core

Version:
34 lines (33 loc) • 1.15 kB
// src/utils/deep-equal.ts /** * Deep equality comparison for comparing two values. * Handles primitives, arrays, objects, and Date instances. */ function deepEqual(a, b) { if (a === b) return true; if (a == null || b == null) return a === b; if (typeof a !== typeof b) return false; if (Array.isArray(a) !== Array.isArray(b)) return false; if (a instanceof Date !== b instanceof Date) return false; if (Array.isArray(a) && Array.isArray(b)) { if (a.length !== b.length) return false; return a.every((item, index) => deepEqual(item, b[index])); } if (a instanceof Date && b instanceof Date) return a.getTime() === b.getTime(); if (typeof a === "object" && typeof b === "object") { const aObj = a; const bObj = b; const aKeys = Object.keys(aObj); const bKeys = Object.keys(bObj); if (aKeys.length !== bKeys.length) return false; return aKeys.every((key) => Object.prototype.hasOwnProperty.call(bObj, key) && deepEqual(aObj[key], bObj[key])); } return false; } Object.defineProperty(exports, "deepEqual", { enumerable: true, get: function() { return deepEqual; } }); //# sourceMappingURL=deep-equal-TMDmByBC.cjs.map