MCPcopy Create free account
hub / github.com/krasimir/react-in-patterns / shallowEqual

Function shallowEqual

code/higher-order-components/public/app.js:567–591  ·  view source on GitHub ↗

* Performs equality by iterating through keys on an object and returning false * when any key has values which are not strictly equal between the arguments. * Returns true when the values of all keys are strictly equal.

(objA, objB)

Source from the content-addressed store, hash-verified

565 * Returns true when the values of all keys are strictly equal.
566 */
567function shallowEqual(objA, objB) {
568 if (is(objA, objB)) {
569 return true;
570 }
571
572 if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
573 return false;
574 }
575
576 var keysA = Object.keys(objA);
577 var keysB = Object.keys(objB);
578
579 if (keysA.length !== keysB.length) {
580 return false;
581 }
582
583 // Test for A's keys different from B.
584 for (var i = 0; i < keysA.length; i++) {
585 if (!hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
586 return false;
587 }
588 }
589
590 return true;
591}
592
593module.exports = shallowEqual;
594},{}],16:[function(require,module,exports){

Callers 2

constructSelectEventFunction · 0.70

Calls 1

isFunction · 0.70

Tested by

no test coverage detected