All files / src/utils shallowEqual.js

86.36% Statements 19/22
78.26% Branches 18/23
100% Functions 1/1
86.36% Lines 19/22
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48        68x   68x       68x 2x     66x       66x 66x   66x 33x     33x     33x 155x   155x       155x 155x   155x   155x 10x       23x    
// Unmodified from: https://github.com/dashed/shallowequal
// (required as shallowEqual isn't exported as an ES6 module and rollup requires this)
 
export default function shallowEqual(objA, objB, compare, compareContext) {
  var ret = compare ? compare.call(compareContext, objA, objB) : void 0;
 
  Iif (ret !== void 0) {
    return !!ret;
  }
 
  if (objA === objB) {
    return true;
  }
 
  Iif (typeof objA !== "object" || !objA || typeof objB !== "object" || !objB) {
    return false;
  }
 
  var keysA = Object.keys(objA);
  var keysB = Object.keys(objB);
 
  if (keysA.length !== keysB.length) {
    return false;
  }
 
  var bHasOwnProperty = Object.prototype.hasOwnProperty.bind(objB);
 
  // Test for A's keys different from B.
  for (var idx = 0; idx < keysA.length; idx++) {
    var key = keysA[idx];
 
    Iif (!bHasOwnProperty(key)) {
      return false;
    }
 
    var valueA = objA[key];
    var valueB = objB[key];
 
    ret = compare ? compare.call(compareContext, valueA, valueB, key) : void 0;
 
    if (ret === false || (ret === void 0 && valueA !== valueB)) {
      return false;
    }
  }
 
  return true;
};