All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.atlassian.prosemirror.model.comparedeep.ts Maven / Gradle / Ivy

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
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy