mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-30 10:16:42 +08:00
Convert react-native-github/Libraries to let/const
Reviewed By: sahrens Differential Revision: D7956042 fbshipit-source-id: 221851aa311f3cdd6326497352b366048db0a1bb
This commit is contained in:
committed by
Facebook Github Bot
parent
266016c521
commit
8f5ebe5952
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var deepDiffer = require('deepDiffer');
|
||||
const deepDiffer = require('deepDiffer');
|
||||
|
||||
describe('deepDiffer', function() {
|
||||
it('should diff primitives of the same type', () => {
|
||||
@@ -95,7 +95,7 @@ describe('deepDiffer', function() {
|
||||
expect(deepDiffer(['a', 'b'], {length: 2, 0: 'a', 1: 'b'})).toBe(true);
|
||||
});
|
||||
it('should diff same object', () => {
|
||||
var obj = [1,[2,3]];
|
||||
const obj = [1,[2,3]];
|
||||
expect(deepDiffer(obj, obj)).toBe(false);
|
||||
});
|
||||
it('should respect maxDepth arg', () => {
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
/*
|
||||
* @returns {bool} true if different, false if equal
|
||||
*/
|
||||
var deepDiffer = function(one: any, two: any, maxDepth: number = -1): bool {
|
||||
const deepDiffer = function(one: any, two: any, maxDepth: number = -1): bool {
|
||||
if (maxDepth === 0) {
|
||||
return true;
|
||||
}
|
||||
@@ -37,22 +37,22 @@ var deepDiffer = function(one: any, two: any, maxDepth: number = -1): bool {
|
||||
}
|
||||
if (Array.isArray(one)) {
|
||||
// We know two is also an array because the constructors are equal
|
||||
var len = one.length;
|
||||
const len = one.length;
|
||||
if (two.length !== len) {
|
||||
return true;
|
||||
}
|
||||
for (var ii = 0; ii < len; ii++) {
|
||||
for (let ii = 0; ii < len; ii++) {
|
||||
if (deepDiffer(one[ii], two[ii], maxDepth - 1)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (var key in one) {
|
||||
for (const key in one) {
|
||||
if (deepDiffer(one[key], two[key], maxDepth - 1)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for (var twoKey in two) {
|
||||
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) {
|
||||
|
||||
@@ -15,14 +15,14 @@ type Inset = {
|
||||
bottom: ?number,
|
||||
}
|
||||
|
||||
var dummyInsets = {
|
||||
const dummyInsets = {
|
||||
top: undefined,
|
||||
left: undefined,
|
||||
right: undefined,
|
||||
bottom: undefined,
|
||||
};
|
||||
|
||||
var insetsDiffer = function(
|
||||
const insetsDiffer = function(
|
||||
one: ?Inset,
|
||||
two: ?Inset
|
||||
): bool {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
* @param {MatrixMath.Matrix} two Second matrix.
|
||||
* @return {boolean} Whether or not the two matrices differ.
|
||||
*/
|
||||
var matricesDiffer = function(one, two) {
|
||||
const matricesDiffer = function(one, two) {
|
||||
if (one === two) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -13,9 +13,9 @@ type Point = {
|
||||
y: ?number,
|
||||
}
|
||||
|
||||
var dummyPoint = {x: undefined, y: undefined};
|
||||
const dummyPoint = {x: undefined, y: undefined};
|
||||
|
||||
var pointsDiffer = function(one: ?Point, two: ?Point): bool {
|
||||
const pointsDiffer = function(one: ?Point, two: ?Point): bool {
|
||||
one = one || dummyPoint;
|
||||
two = two || dummyPoint;
|
||||
return one !== two && (
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var dummySize = {width: undefined, height: undefined};
|
||||
const dummySize = {width: undefined, height: undefined};
|
||||
|
||||
var sizesDiffer = function(one, two) {
|
||||
const sizesDiffer = function(one, two) {
|
||||
one = one || dummySize;
|
||||
two = two || dummySize;
|
||||
return one !== two && (
|
||||
|
||||
Reference in New Issue
Block a user