initial commit taken from gitlab.lrz.de

This commit is contained in:
privatereese
2018-08-24 18:09:42 +02:00
parent ae54ed4c48
commit fc05486403
28494 changed files with 2159823 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @providesModule deepDiffer
* @flow
*/
'use strict';
/*
* @returns {bool} true if different, false if equal
*/
var deepDiffer = function(one: any, two: any): bool {
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
return false;
}
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
var len = one.length;
if (two.length !== len) {
return true;
}
for (var ii = 0; ii < len; ii++) {
if (deepDiffer(one[ii], two[ii])) {
return true;
}
}
} else {
for (var key in one) {
if (deepDiffer(one[key], two[key])) {
return true;
}
}
for (var 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;

View File

@@ -0,0 +1,40 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @providesModule insetsDiffer
* @flow
*/
'use strict';
type Inset = {
top: ?number,
left: ?number,
right: ?number,
bottom: ?number,
}
var dummyInsets = {
top: undefined,
left: undefined,
right: undefined,
bottom: undefined,
};
var insetsDiffer = function(
one: ?Inset,
two: ?Inset
): bool {
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;

View File

@@ -0,0 +1,42 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @providesModule matricesDiffer
*/
'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.
*/
var 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[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;

View File

@@ -0,0 +1,28 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @providesModule pointsDiffer
* @flow
*/
'use strict';
type Point = {
x: ?number,
y: ?number,
}
var dummyPoint = {x: undefined, y: undefined};
var pointsDiffer = function(one: ?Point, two: ?Point): bool {
one = one || dummyPoint;
two = two || dummyPoint;
return one !== two && (
one.x !== two.x ||
one.y !== two.y
);
};
module.exports = pointsDiffer;

View File

@@ -0,0 +1,22 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @providesModule sizesDiffer
*/
'use strict';
var dummySize = {width: undefined, height: undefined};
var sizesDiffer = function(one, two) {
one = one || dummySize;
two = two || dummySize;
return one !== two && (
one.width !== two.width ||
one.height !== two.height
);
};
module.exports = sizesDiffer;