Skip to content

Commit

Permalink
Remove var in Libraries/emitter/* (#22087)
Browse files Browse the repository at this point in the history
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: #22087

Differential Revision: D12918444

Pulled By: TheSavior

fbshipit-source-id: 630ccb283fd6c3118a22124a656038eac4a88599
  • Loading branch information
binaryta authored and facebook-github-bot committed Nov 4, 2018
1 parent 499c195 commit cf70870
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Libraries/vendor/emitter/EventValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 = [];

Expand Down

0 comments on commit cf70870

Please sign in to comment.