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

Function shallowEqual

code/styling/public/app.js:446–470  ·  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

444 * Returns true when the values of all keys are strictly equal.
445 */
446function shallowEqual(objA, objB) {
447 if (is(objA, objB)) {
448 return true;
449 }
450
451 if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
452 return false;
453 }
454
455 var keysA = Object.keys(objA);
456 var keysB = Object.keys(objB);
457
458 if (keysA.length !== keysB.length) {
459 return false;
460 }
461
462 // Test for A's keys different from B.
463 for (var i = 0; i < keysA.length; i++) {
464 if (!hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
465 return false;
466 }
467 }
468
469 return true;
470}
471
472module.exports = shallowEqual;
473},{}],14:[function(require,module,exports){

Callers 2

constructSelectEventFunction · 0.70

Calls 1

isFunction · 0.70

Tested by

no test coverage detected