deepDiffer() — react Function Reference
Architecture documentation for the deepDiffer() function in deepDiffer.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD 4e10271b_2eaf_7c12_a408_b955425e888c["deepDiffer()"] f095975f_d060_c110_1c71_056d3e27b5d0["deepDiffer.js"] 4e10271b_2eaf_7c12_a408_b955425e888c -->|defined in| f095975f_d060_c110_1c71_056d3e27b5d0 7f45d09a_b4f6_1ee2_478f_eb8fcecc6629["diff()"] 7f45d09a_b4f6_1ee2_478f_eb8fcecc6629 -->|calls| 4e10271b_2eaf_7c12_a408_b955425e888c style 4e10271b_2eaf_7c12_a408_b955425e888c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/react-native-renderer/src/__mocks__/react-native/Libraries/ReactPrivate/deepDiffer.js lines 16–70
function deepDiffer(
one: any,
two: any,
maxDepthOrOptions: Options | number = -1,
maybeOptions?: Options,
): boolean {
const options =
typeof maxDepthOrOptions === 'number' ? maybeOptions : maxDepthOrOptions;
const maxDepth =
typeof maxDepthOrOptions === 'number' ? maxDepthOrOptions : -1;
if (maxDepth === 0) {
return true;
}
if (one === two) {
// Short circuit on identical object references instead of traversing them.
return false;
}
if (typeof one === 'function' && typeof two === 'function') {
// We consider all functions equal unless explicitly configured otherwise
let unsafelyIgnoreFunctions =
options == null ? null : options.unsafelyIgnoreFunctions;
if (unsafelyIgnoreFunctions == null) {
unsafelyIgnoreFunctions = true;
}
return !unsafelyIgnoreFunctions;
}
if (typeof one !== 'object' || one === null) {
// Primitives can be directly compared
return one !== two;
}
if (typeof two !== 'object' || two === null) {
// We know they are different because the previous case would have triggered
// otherwise.
return true;
}
if (one.constructor !== two.constructor) {
return true;
}
if (Array.isArray(one)) {
// We know two is also an array because the constructors are equal
const len = one.length;
if (two.length !== len) {
return true;
}
for (let ii = 0; ii < len; ii++) {
if (deepDiffer(one[ii], two[ii], maxDepth - 1, options)) {
return true;
}
}
} else {
for (const key in one) {
if (deepDiffer(one[key], two[key], maxDepth - 1, options)) {
return true;
}
}
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does deepDiffer() do?
deepDiffer() is a function in the react codebase, defined in packages/react-native-renderer/src/__mocks__/react-native/Libraries/ReactPrivate/deepDiffer.js.
Where is deepDiffer() defined?
deepDiffer() is defined in packages/react-native-renderer/src/__mocks__/react-native/Libraries/ReactPrivate/deepDiffer.js at line 16.
What calls deepDiffer()?
deepDiffer() is called by 1 function(s): diff.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free