mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-23 03:50:11 +08:00
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:
committed by
Facebook Github Bot
parent
499c195eba
commit
cf70870caa
10
Libraries/vendor/emitter/EventValidator.js
vendored
10
Libraries/vendor/emitter/EventValidator.js
vendored
@@ -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 = [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user