Remove var in Libraries/emitter/* (#22087)

Summary:
Replaces the keywords var with const in Libraries/emitter/EventValidator.js

If this PR fixes an issue, type "Fixes #issueNumber" to automatically close the issue when the PR is merged.

_Pull requests that expand test coverage are more likely to get reviewed. Add a test case whenever possible!_

- [x] Check npm run flow
- [x] Check npm run flow-check-ios
- [x] Check npm run flow-check-android

[GENERAL] [ENHANCEMENT] [Libraries/emitter] - remove `var`
Pull Request resolved: https://github.com/facebook/react-native/pull/22087

Differential Revision: D12918444

Pulled By: TheSavior

fbshipit-source-id: 630ccb283fd6c3118a22124a656038eac4a88599
This commit is contained in:
Tnarita0000
2018-11-03 23:00:13 -07:00
committed by Facebook Github Bot
parent 499c195eba
commit cf70870caa

View File

@@ -71,21 +71,21 @@ if (__DEV__) {
}
};
var closestTypeFor = function(type, allowedTypes) {
const closestTypeFor = function(type, allowedTypes) {
const typeRecommendations = allowedTypes.map(
typeRecommendationFor.bind(this, type),
);
return typeRecommendations.sort(recommendationSort)[0];
};
var typeRecommendationFor = function(type, recommendedType) {
const typeRecommendationFor = function(type, recommendedType) {
return {
type: recommendedType,
distance: damerauLevenshteinDistance(type, recommendedType),
};
};
var recommendationSort = function(recommendationA, recommendationB) {
const recommendationSort = function(recommendationA, recommendationB) {
if (recommendationA.distance < recommendationB.distance) {
return -1;
} else if (recommendationA.distance > recommendationB.distance) {
@@ -95,11 +95,11 @@ if (__DEV__) {
}
};
var isCloseEnough = function(closestType, actualType) {
const isCloseEnough = function(closestType, actualType) {
return closestType.distance / actualType.length < 0.334;
};
var damerauLevenshteinDistance = function(a, b) {
const damerauLevenshteinDistance = function(a, b) {
let i, j;
const d = [];