@@ -28,7 +28,7 @@ export interface IMatch {
2828export function or ( ...filter : IFilter [ ] ) : IFilter {
2929 return function ( word : string , wordToMatchAgainst : string ) : IMatch [ ] | null {
3030 for ( let i = 0 , len = filter . length ; i < len ; i ++ ) {
31- let match = filter [ i ] ( word , wordToMatchAgainst ) ;
31+ const match = filter [ i ] ( word , wordToMatchAgainst ) ;
3232 if ( match ) {
3333 return match ;
3434 }
@@ -64,7 +64,7 @@ function _matchesPrefix(ignoreCase: boolean, word: string, wordToMatchAgainst: s
6464// Contiguous Substring
6565
6666export function matchesContiguousSubString ( word : string , wordToMatchAgainst : string ) : IMatch [ ] | null {
67- let index = wordToMatchAgainst . toLowerCase ( ) . indexOf ( word . toLowerCase ( ) ) ;
67+ const index = wordToMatchAgainst . toLowerCase ( ) . indexOf ( word . toLowerCase ( ) ) ;
6868 if ( index === - 1 ) {
6969 return null ;
7070 }
@@ -136,7 +136,7 @@ function join(head: IMatch, tail: IMatch[]): IMatch[] {
136136
137137function nextAnchor ( camelCaseWord : string , start : number ) : number {
138138 for ( let i = start ; i < camelCaseWord . length ; i ++ ) {
139- let c = camelCaseWord . charCodeAt ( i ) ;
139+ const c = camelCaseWord . charCodeAt ( i ) ;
140140 if ( isUpper ( c ) || isNumber ( c ) || ( i > 0 && ! isAlphanumeric ( camelCaseWord . charCodeAt ( i - 1 ) ) ) ) {
141141 return i ;
142142 }
@@ -184,10 +184,10 @@ function analyzeCamelCaseWord(word: string): ICamelCaseAnalysis {
184184 if ( isNumber ( code ) ) { numeric ++ ; }
185185 }
186186
187- let upperPercent = upper / word . length ;
188- let lowerPercent = lower / word . length ;
189- let alphaPercent = alpha / word . length ;
190- let numericPercent = numeric / word . length ;
187+ const upperPercent = upper / word . length ;
188+ const lowerPercent = lower / word . length ;
189+ const alphaPercent = alpha / word . length ;
190+ const numericPercent = numeric / word . length ;
191191
192192 return { upperPercent, lowerPercent, alphaPercent, numericPercent } ;
193193}
@@ -307,7 +307,7 @@ function _matchesWords(word: string, target: string, i: number, j: number, conti
307307
308308function nextWord ( word : string , start : number ) : number {
309309 for ( let i = start ; i < word . length ; i ++ ) {
310- let c = word . charCodeAt ( i ) ;
310+ const c = word . charCodeAt ( i ) ;
311311 if ( isWhitespace ( c ) || ( i > 0 && isWhitespace ( word . charCodeAt ( i - 1 ) ) ) ) {
312312 return i ;
313313 }
@@ -334,7 +334,7 @@ export function matchesFuzzy(word: string, wordToMatchAgainst: string, enableSep
334334 }
335335
336336 // RegExp Filter
337- let match = regexp . exec ( wordToMatchAgainst ) ;
337+ const match = regexp . exec ( wordToMatchAgainst ) ;
338338 if ( match ) {
339339 return [ { start : match . index , end : match . index + match [ 0 ] . length } ] ;
340340 }
@@ -348,7 +348,7 @@ export function matchesFuzzy(word: string, wordToMatchAgainst: string, enableSep
348348 * powerfull than `matchesFuzzy`
349349 */
350350export function matchesFuzzy2 ( pattern : string , word : string ) : IMatch [ ] | null {
351- let score = fuzzyScore ( pattern , pattern . toLowerCase ( ) , 0 , word , word . toLowerCase ( ) , 0 , true ) ;
351+ const score = fuzzyScore ( pattern , pattern . toLowerCase ( ) , 0 , word , word . toLowerCase ( ) , 0 , true ) ;
352352 return score ? createMatches ( score ) : null ;
353353}
354354
@@ -404,7 +404,7 @@ function initTable() {
404404 row . push ( - i ) ;
405405 }
406406 for ( let i = 0 ; i <= _maxLen ; i ++ ) {
407- let thisRow = row . slice ( 0 ) ;
407+ const thisRow = row . slice ( 0 ) ;
408408 thisRow [ 0 ] = - i ;
409409 table . push ( thisRow ) ;
410410 }
@@ -566,9 +566,9 @@ export function fuzzyScore(pattern: string, patternLow: string, patternPos: numb
566566
567567 _scores [ patternPos ] [ wordPos ] = score ;
568568
569- let diag = _table [ patternPos - 1 ] [ wordPos - 1 ] + ( score > 1 ? 1 : score ) ;
570- let top = _table [ patternPos - 1 ] [ wordPos ] + - 1 ;
571- let left = _table [ patternPos ] [ wordPos - 1 ] + - 1 ;
569+ const diag = _table [ patternPos - 1 ] [ wordPos - 1 ] + ( score > 1 ? 1 : score ) ;
570+ const top = _table [ patternPos - 1 ] [ wordPos ] + - 1 ;
571+ const left = _table [ patternPos ] [ wordPos - 1 ] + - 1 ;
572572
573573 if ( left >= top ) {
574574 // left or diag
@@ -635,8 +635,8 @@ function _findAllMatches2(patternPos: number, wordPos: number, total: number, ma
635635
636636 while ( patternPos > _patternStartPos && wordPos > 0 ) {
637637
638- let score = _scores [ patternPos ] [ wordPos ] ;
639- let arrow = _arrows [ patternPos ] [ wordPos ] ;
638+ const score = _scores [ patternPos ] [ wordPos ] ;
639+ const arrow = _arrows [ patternPos ] [ wordPos ] ;
640640
641641 if ( arrow === Arrow . Left ) {
642642 // left -> no match, skip a word character
@@ -733,11 +733,11 @@ function fuzzyScoreWithPermutations(pattern: string, lowPattern: string, pattern
733733 // permutations of the pattern to find a better match. The
734734 // permutations only swap neighbouring characters, e.g
735735 // `cnoso` becomes `conso`, `cnsoo`, `cnoos`.
736- let tries = Math . min ( 7 , pattern . length - 1 ) ;
736+ const tries = Math . min ( 7 , pattern . length - 1 ) ;
737737 for ( let movingPatternPos = patternPos + 1 ; movingPatternPos < tries ; movingPatternPos ++ ) {
738- let newPattern = nextTypoPermutation ( pattern , movingPatternPos ) ;
738+ const newPattern = nextTypoPermutation ( pattern , movingPatternPos ) ;
739739 if ( newPattern ) {
740- let candidate = fuzzyScore ( newPattern , newPattern . toLowerCase ( ) , patternPos , word , lowWord , wordPos , firstMatchCanBeWeak ) ;
740+ const candidate = fuzzyScore ( newPattern , newPattern . toLowerCase ( ) , patternPos , word , lowWord , wordPos , firstMatchCanBeWeak ) ;
741741 if ( candidate ) {
742742 candidate [ 0 ] -= 3 ; // permutation penalty
743743 if ( ! top || candidate [ 0 ] > top [ 0 ] ) {
@@ -757,8 +757,8 @@ function nextTypoPermutation(pattern: string, patternPos: number): string | unde
757757 return undefined ;
758758 }
759759
760- let swap1 = pattern [ patternPos ] ;
761- let swap2 = pattern [ patternPos + 1 ] ;
760+ const swap1 = pattern [ patternPos ] ;
761+ const swap2 = pattern [ patternPos + 1 ] ;
762762
763763 if ( swap1 === swap2 ) {
764764 return undefined ;
0 commit comments