UNPKG

@mastra/core

Version:
29 lines (28 loc) • 1.06 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; } export { deepEqual as t }; //# sourceMappingURL=deep-equal-d1xU02ag.js.map