All files / src/connect/utils shallowEqual.js

87.5% Statements 14/16
72% Branches 18/25
100% Functions 2/2
92.86% Lines 13/14
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 331x     187x 78x   109x         121x   62x         62x 62x   62x   62x 66x   47x       15x    
const hasOwn = Object.prototype.hasOwnProperty
 
function is(x, y) {
  if (x === y) {
    return x !== 0 || y !== 0 || 1 / x === 1 / y
  } else {
    return x !== x && y !== y
  }
}
 
export default function shallowEqual(objA, objB) {
  if (is(objA, objB)) return true
 
  Iif (typeof objA !== 'object' || objA === null ||
      typeof objB !== 'object' || objB === null) {
    return false
  }
 
  const keysA = Object.keys(objA)
  const keysB = Object.keys(objB)
 
  Iif (keysA.length !== keysB.length) return false
 
  for (let i = 0; i < keysA.length; i++) {
    if (!hasOwn.call(objB, keysA[i]) ||
        !is(objA[keysA[i]], objB[keysA[i]])) {
      return false
    }
  }
 
  return true
}