yeet
This commit is contained in:
101
node_modules/react-native/Libraries/Utilities/differ/deepDiffer.js
generated
vendored
Normal file
101
node_modules/react-native/Libraries/Utilities/differ/deepDiffer.js
generated
vendored
Normal file
@ -0,0 +1,101 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
* @flow
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
let logListeners;
|
||||
|
||||
type LogListeners = {|
|
||||
+onDifferentFunctionsIgnored: (nameOne: ?string, nameTwo: ?string) => void,
|
||||
|};
|
||||
|
||||
type Options = {|+unsafelyIgnoreFunctions?: boolean|};
|
||||
|
||||
function unstable_setLogListeners(listeners: ?LogListeners) {
|
||||
logListeners = listeners;
|
||||
}
|
||||
|
||||
/*
|
||||
* @returns {bool} true if different, false if equal
|
||||
*/
|
||||
const deepDiffer = function(
|
||||
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?.unsafelyIgnoreFunctions;
|
||||
if (unsafelyIgnoreFunctions == null) {
|
||||
if (
|
||||
logListeners &&
|
||||
logListeners.onDifferentFunctionsIgnored &&
|
||||
(!options || !('unsafelyIgnoreFunctions' in options))
|
||||
) {
|
||||
logListeners.onDifferentFunctionsIgnored(one.name, two.name);
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
for (const twoKey in two) {
|
||||
// The only case we haven't checked yet is keys that are in two but aren't
|
||||
// in one, which means they are different.
|
||||
if (one[twoKey] === undefined && two[twoKey] !== undefined) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
module.exports = deepDiffer;
|
||||
module.exports.unstable_setLogListeners = unstable_setLogListeners;
|
40
node_modules/react-native/Libraries/Utilities/differ/insetsDiffer.js
generated
vendored
Normal file
40
node_modules/react-native/Libraries/Utilities/differ/insetsDiffer.js
generated
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
* @flow
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
type Inset = {
|
||||
top: ?number,
|
||||
left: ?number,
|
||||
right: ?number,
|
||||
bottom: ?number,
|
||||
...
|
||||
};
|
||||
|
||||
const dummyInsets = {
|
||||
top: undefined,
|
||||
left: undefined,
|
||||
right: undefined,
|
||||
bottom: undefined,
|
||||
};
|
||||
|
||||
const insetsDiffer = function(one: Inset, two: Inset): boolean {
|
||||
one = one || dummyInsets;
|
||||
two = two || dummyInsets;
|
||||
return (
|
||||
one !== two &&
|
||||
(one.top !== two.top ||
|
||||
one.left !== two.left ||
|
||||
one.right !== two.right ||
|
||||
one.bottom !== two.bottom)
|
||||
);
|
||||
};
|
||||
|
||||
module.exports = insetsDiffer;
|
47
node_modules/react-native/Libraries/Utilities/differ/matricesDiffer.js
generated
vendored
Normal file
47
node_modules/react-native/Libraries/Utilities/differ/matricesDiffer.js
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Unrolls an array comparison specially for matrices. Prioritizes
|
||||
* checking of indices that are most likely to change so that the comparison
|
||||
* bails as early as possible.
|
||||
*
|
||||
* @param {MatrixMath.Matrix} one First matrix.
|
||||
* @param {MatrixMath.Matrix} two Second matrix.
|
||||
* @return {boolean} Whether or not the two matrices differ.
|
||||
*/
|
||||
const matricesDiffer = function(one, two) {
|
||||
if (one === two) {
|
||||
return false;
|
||||
}
|
||||
return (
|
||||
!one ||
|
||||
!two ||
|
||||
one[12] !== two[12] ||
|
||||
one[13] !== two[13] ||
|
||||
one[14] !== two[14] ||
|
||||
one[5] !== two[5] ||
|
||||
one[10] !== two[10] ||
|
||||
one[0] !== two[0] ||
|
||||
one[1] !== two[1] ||
|
||||
one[2] !== two[2] ||
|
||||
one[3] !== two[3] ||
|
||||
one[4] !== two[4] ||
|
||||
one[6] !== two[6] ||
|
||||
one[7] !== two[7] ||
|
||||
one[8] !== two[8] ||
|
||||
one[9] !== two[9] ||
|
||||
one[11] !== two[11] ||
|
||||
one[15] !== two[15]
|
||||
);
|
||||
};
|
||||
|
||||
module.exports = matricesDiffer;
|
27
node_modules/react-native/Libraries/Utilities/differ/pointsDiffer.js
generated
vendored
Normal file
27
node_modules/react-native/Libraries/Utilities/differ/pointsDiffer.js
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
* @flow
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
type Point = {
|
||||
x: ?number,
|
||||
y: ?number,
|
||||
...
|
||||
};
|
||||
|
||||
const dummyPoint = {x: undefined, y: undefined};
|
||||
|
||||
const pointsDiffer = function(one: ?Point, two: ?Point): boolean {
|
||||
one = one || dummyPoint;
|
||||
two = two || dummyPoint;
|
||||
return one !== two && (one.x !== two.x || one.y !== two.y);
|
||||
};
|
||||
|
||||
module.exports = pointsDiffer;
|
20
node_modules/react-native/Libraries/Utilities/differ/sizesDiffer.js
generated
vendored
Normal file
20
node_modules/react-native/Libraries/Utilities/differ/sizesDiffer.js
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const dummySize = {width: undefined, height: undefined};
|
||||
|
||||
const sizesDiffer = function(one, two) {
|
||||
one = one || dummySize;
|
||||
two = two || dummySize;
|
||||
return one !== two && (one.width !== two.width || one.height !== two.height);
|
||||
};
|
||||
|
||||
module.exports = sizesDiffer;
|
Reference in New Issue
Block a user