shallowEqual.js — react Source File
Architecture documentation for shallowEqual.js, a javascript file in the react codebase. 3 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 453d8884_196c_9b47_f492_31e5c07005e7["shallowEqual.js"] 6e14608c_da3e_3b32_c806_aa3aab42a0c9["objectIs.js"] 453d8884_196c_9b47_f492_31e5c07005e7 --> 6e14608c_da3e_3b32_c806_aa3aab42a0c9 dab343e7_d491_ab84_5374_66898c315624["is"] 453d8884_196c_9b47_f492_31e5c07005e7 --> dab343e7_d491_ab84_5374_66898c315624 89ac798a_a938_334b_3064_cf5384f9cb5c["hasOwnProperty.js"] 453d8884_196c_9b47_f492_31e5c07005e7 --> 89ac798a_a938_334b_3064_cf5384f9cb5c style 453d8884_196c_9b47_f492_31e5c07005e7 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
import is from './objectIs';
import hasOwnProperty from './hasOwnProperty';
/**
* 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.
*/
function shallowEqual(objA: mixed, objB: mixed): boolean {
if (is(objA, objB)) {
return true;
}
if (
typeof objA !== 'object' ||
objA === null ||
typeof objB !== 'object' ||
objB === null
) {
return false;
}
const keysA = Object.keys(objA);
const keysB = Object.keys(objB);
if (keysA.length !== keysB.length) {
return false;
}
// Test for A's keys different from B.
for (let i = 0; i < keysA.length; i++) {
const currentKey = keysA[i];
if (
!hasOwnProperty.call(objB, currentKey) ||
// $FlowFixMe[incompatible-use] lost refinement of `objB`
!is(objA[currentKey], objB[currentKey])
) {
return false;
}
}
return true;
}
export default shallowEqual;
Domain
Subdomains
Functions
Dependencies
Source
Frequently Asked Questions
What does shallowEqual.js do?
shallowEqual.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Optimization subdomain.
What functions are defined in shallowEqual.js?
shallowEqual.js defines 1 function(s): shallowEqual.
What does shallowEqual.js depend on?
shallowEqual.js imports 3 module(s): hasOwnProperty.js, is, objectIs.js.
Where is shallowEqual.js in the architecture?
shallowEqual.js is located at packages/shared/shallowEqual.js (domain: BabelCompiler, subdomain: Optimization, directory: packages/shared).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free