com.atlassian.prosemirror.model.comparedeep.ts Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of model Show documentation
Show all versions of model Show documentation
ProseMirror's document model
The newest version!
export function compareDeep(a: any, b: any) {
if (a === b) return true
if (!(a && typeof a == "object") ||
!(b && typeof b == "object")) return false
let array = Array.isArray(a)
if (Array.isArray(b) != array) return false
if (array) {
if (a.length != b.length) return false
for (let i = 0; i < a.length; i++) if (!compareDeep(a[i], b[i])) return false
} else {
for (let p in a) if (!(p in b) || !compareDeep(a[p], b[p])) return false
for (let p in b) if (!(p in a)) return false
}
return true
}