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

Function shallowEqual

code/communication/public/app.js:608–632  ·  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

606 * Returns true when the values of all keys are strictly equal.
607 */
608function shallowEqual(objA, objB) {
609 if (is(objA, objB)) {
610 return true;
611 }
612
613 if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
614 return false;
615 }
616
617 var keysA = Object.keys(objA);
618 var keysB = Object.keys(objB);
619
620 if (keysA.length !== keysB.length) {
621 return false;
622 }
623
624 // Test for A's keys different from B.
625 for (var i = 0; i < keysA.length; i++) {
626 if (!hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
627 return false;
628 }
629 }
630
631 return true;
632}
633
634module.exports = shallowEqual;
635},{}],15:[function(require,module,exports){

Callers 2

constructSelectEventFunction · 0.70

Calls 1

isFunction · 0.70

Tested by

no test coverage detected