src/json-patch.js
function compare(a, b) {
  let isIdentical = true;

  if (isObject(a) && isObject(b)) {
    if (Object.keys(a).length !== Object.keys(b).length) {
      return false;
    }
    Object.keys(a).forEach((key) => {
      if (!compare(a[key], b[key])) {
        isIdentical = false;
      }
    });
    return isIdentical;
  } if (isArray(a) && isArray(b)) {
    if (a.length !== b.length) {
      return false;
    }
    for (let i = 0, l = a.length; i < l; i += 1) {
      if (!compare(a[i], b[i])) {
        return false;
      }
    }
    return true;
  }
  return a === b;
}
function compare(a, b) {
  let isIdentical = true;

  if (isObject(a) && isObject(b)) {
    if (Object.keys(a).length !== Object.keys(b).length) {
      return false;
    }
    Object.keys(a).forEach((key) => {
      if (!compare(a[key], b[key])) {
        isIdentical = false;
      }
    });
    return isIdentical;
  } if (isArray(a) && isArray(b)) {
    if (a.length !== b.length) {
      return false;
    }
    for (let i = 0, l = a.length; i < l; i += 1) {
      if (!compare(a[i], b[i])) {
        return false;
      }
    }
    return true;
  }
  return a === b;
}
function compare ( a , b ) { let isIdentical = true ; if ( isObject ( a ) && isObject ( b ) ) { if ( Object . keys ( a ) . length !== Object . keys ( b ) . length ) { return false ; } Object . keys ( a ) . forEach ( ( key ) => { if ( ! compare ( a [ key ] , b [ key ] ) ) { isIdentical = false ; } } ) ; return isIdentical ; } if ( isArray ( a ) && isArray ( b ) ) { if ( a . length !== b . length ) { return false ; } for ( let i = 0 , l = a . length ; i < l ; i += 1 ) { if ( ! compare ( a [ i ] , b [ i ] ) ) { return false ; } } return true ; } return a === b ; }
Compare an object with another, could be object, array, number, string, bool.
@private
@param {Object} a The first object to compare
@param {Object} a The second object to compare
@returns {Boolean} Whether the objects are identical
Compare an object with another could be object array number string bool .