@@ -95,15 +95,15 @@ const POSTPROCESS_FIXLIST = [
95
95
] ;
96
96
/* eslint-enable no-multi-spaces */
97
97
98
- function replaceMatch ( matches , is , regex , replacement ) {
98
+ function replaceMatch ( matches , inputString , regex , replacement ) {
99
99
// get reference to first set of parentheses
100
100
const a = matches [ 1 ] || '' ;
101
101
102
102
// get reference to last set of parentheses
103
103
const b = matches [ matches . length - 1 ] || '' ;
104
104
105
105
// compile replace string
106
- return is . replace ( regex , [ a , replacement , b ] . join ( '' ) ) ;
106
+ return inputString . replace ( regex , [ a , replacement , b ] . join ( '' ) ) ;
107
107
}
108
108
109
109
/*
@@ -112,26 +112,26 @@ function replaceMatch(matches, is, regex, replacement) {
112
112
* @param is the input string
113
113
* @param fixes the list of fix objects to apply
114
114
*/
115
- function runFixes ( is , fixes ) {
115
+ function runFixes ( inputString , fixes ) {
116
116
fixes . forEach ( function ( fix ) {
117
117
const [ regex , replacement ] = fix ;
118
118
let matches ;
119
119
120
120
if ( regex . global ) {
121
- let oldis ;
122
- while ( ( matches = regex . exec ( is ) ) ) {
123
- oldis = is ;
124
- is = replaceMatch ( matches , is , regex , replacement ) ;
125
- if ( oldis === is ) {
121
+ let oldInputString ;
122
+ while ( ( matches = regex . exec ( inputString ) ) ) {
123
+ oldInputString = inputString ;
124
+ inputString = replaceMatch ( matches , inputString , regex , replacement ) ;
125
+ if ( oldInputString === inputString ) {
126
126
break ;
127
127
}
128
128
}
129
- } else if ( ( matches = is . match ( regex ) ) !== null ) {
130
- is = replaceMatch ( matches , is , regex , replacement ) ;
129
+ } else if ( ( matches = inputString . match ( regex ) ) !== null ) {
130
+ inputString = replaceMatch ( matches , inputString , regex , replacement ) ;
131
131
}
132
132
} ) ;
133
133
134
- return is ;
134
+ return inputString ;
135
135
}
136
136
137
137
const DefaultMode = {
@@ -155,26 +155,26 @@ const DefaultMode = {
155
155
* - Convert 12', 12'', 12", 12in, and 12inch to '12" ' (followed by space).
156
156
* - Do not convert strings like 80's.
157
157
*/
158
- fixVinylSizes ( is ) {
159
- return is
158
+ fixVinylSizes ( inputString ) {
159
+ return inputString
160
160
. replace ( / ( \s + | \( ) ( 7 | 1 0 | 1 2 ) (?: i n c h \b | i n \b | ' | ' ' | " ) ( [ ^ s ] | $ ) / ig, '$1$2"$3' )
161
161
. replace ( / ( (?: \s + | \( ) (?: 7 | 1 0 | 1 2 ) " ) ( [ ^ ) , \s ] ) / , '$1 $2' ) ;
162
162
} ,
163
163
164
- isLowerCaseWord ( w ) {
165
- return LOWER_CASE_WORDS . test ( w ) ;
164
+ isLowerCaseWord ( word ) {
165
+ return LOWER_CASE_WORDS . test ( word ) ;
166
166
} ,
167
167
168
- isRomanNumber ( w ) {
169
- return getBooleanCookie ( 'guesscase_roman' ) && ROMAN_NUMERALS . test ( w ) ;
168
+ isRomanNumber ( word ) {
169
+ return getBooleanCookie ( 'guesscase_roman' ) && ROMAN_NUMERALS . test ( word ) ;
170
170
} ,
171
171
172
172
isSentenceCaps ( ) {
173
173
return true ;
174
174
} ,
175
175
176
- isUpperCaseWord ( w ) {
177
- return UPPER_CASE_WORDS . test ( w ) ;
176
+ isUpperCaseWord ( word ) {
177
+ return UPPER_CASE_WORDS . test ( word ) ;
178
178
} ,
179
179
180
180
name : '' ,
@@ -188,23 +188,23 @@ const DefaultMode = {
188
188
*/
189
189
prepExtraTitleInfo ( words ) {
190
190
const lastWord = words . length - 1 ;
191
- let wi = lastWord ;
191
+ let wordIndex = lastWord ;
192
192
let handlePreProcess = false ;
193
193
194
- while ( wi >= 0 && (
194
+ while ( wordIndex >= 0 && (
195
195
// skip whitespace
196
- ( words [ wi ] === ' ' ) ||
196
+ ( words [ wordIndex ] === ' ' ) ||
197
197
198
198
// vinyl (7" or 12")
199
- ( words [ wi ] === '"' &&
200
- ( words [ wi - 1 ] === '7' || words [ wi - 1 ] === '12' ) ) ||
201
- ( ( words [ wi + 1 ] || '' ) === '"' &&
202
- ( words [ wi ] === '7' || words [ wi ] === '12' ) ) ||
199
+ ( words [ wordIndex ] === '"' &&
200
+ ( words [ wordIndex - 1 ] === '7' || words [ wordIndex - 1 ] === '12' ) ) ||
201
+ ( ( words [ wordIndex + 1 ] || '' ) === '"' &&
202
+ ( words [ wordIndex ] === '7' || words [ wordIndex ] === '12' ) ) ||
203
203
204
- isPrepBracketWord ( words [ wi ] )
204
+ isPrepBracketWord ( words [ wordIndex ] )
205
205
) ) {
206
206
handlePreProcess = true ;
207
- wi -- ;
207
+ wordIndex -- ;
208
208
}
209
209
210
210
/*
@@ -218,35 +218,35 @@ const DefaultMode = {
218
218
* trackback the skipped spaces spaces, and then slurp the next word, so
219
219
* see which word we found.
220
220
*/
221
- if ( wi < lastWord ) {
221
+ if ( wordIndex < lastWord ) {
222
222
// the word at wi broke out of the loop above, is not extra title info
223
- wi ++ ;
224
- while ( words [ wi ] === ' ' && wi < lastWord ) {
225
- wi ++ ; // skip whitespace
223
+ wordIndex ++ ;
224
+ while ( words [ wordIndex ] === ' ' && wordIndex < lastWord ) {
225
+ wordIndex ++ ; // skip whitespace
226
226
}
227
227
228
228
/*
229
229
* If we have a single word that needs to be put in parentheses, consult
230
230
* the list of words were we don't do that, otherwise continue.
231
231
*/
232
232
const probe = words [ lastWord ] ;
233
- if ( wi === lastWord && isPrepBracketSingleWord ( probe ) ) {
233
+ if ( wordIndex === lastWord && isPrepBracketSingleWord ( probe ) ) {
234
234
handlePreProcess = false ;
235
235
}
236
236
237
- if ( handlePreProcess && wi > 0 && wi <= lastWord ) {
238
- let newWords = words . slice ( 0 , wi ) ;
237
+ if ( handlePreProcess && wordIndex > 0 && wordIndex <= lastWord ) {
238
+ let newWords = words . slice ( 0 , wordIndex ) ;
239
239
240
- if ( newWords [ wi - 1 ] === '(' ) {
240
+ if ( newWords [ wordIndex - 1 ] === '(' ) {
241
241
newWords . pop ( ) ;
242
242
}
243
243
244
- if ( newWords [ wi - 1 ] === '-' ) {
244
+ if ( newWords [ wordIndex - 1 ] === '-' ) {
245
245
newWords . pop ( ) ;
246
246
}
247
247
248
248
newWords . push ( '(' ) ;
249
- newWords = newWords . concat ( words . slice ( wi , words . length ) ) ;
249
+ newWords = newWords . concat ( words . slice ( wordIndex , words . length ) ) ;
250
250
newWords . push ( ')' ) ;
251
251
words = newWords ;
252
252
}
@@ -263,24 +263,24 @@ const DefaultMode = {
263
263
*
264
264
* keschte 2005-11-10 first version
265
265
*/
266
- preProcessTitles ( is ) {
267
- return runFixes ( is , PREPROCESS_FIXLIST ) ;
266
+ preProcessTitles ( inputString ) {
267
+ return runFixes ( inputString , PREPROCESS_FIXLIST ) ;
268
268
} ,
269
269
270
270
/*
271
271
* Collect words from processed wordlist and apply minor fixes that
272
272
* aren't handled in the specific function.
273
273
*/
274
- runPostProcess ( is ) {
275
- return runFixes ( is , POSTPROCESS_FIXLIST ) ;
274
+ runPostProcess ( inputString ) {
275
+ return runFixes ( inputString , POSTPROCESS_FIXLIST ) ;
276
276
} ,
277
277
278
- toLowerCase ( str ) {
279
- return str . toLowerCase ( ) ;
278
+ toLowerCase ( string ) {
279
+ return string . toLowerCase ( ) ;
280
280
} ,
281
281
282
- toUpperCase ( str ) {
283
- return str . toUpperCase ( ) ;
282
+ toUpperCase ( string ) {
283
+ return string . toUpperCase ( ) ;
284
284
} ,
285
285
} ;
286
286
@@ -302,22 +302,22 @@ export const English = {
302
302
303
303
name : 'English' ,
304
304
305
- runPostProcess ( is ) {
306
- is = DefaultMode . runPostProcess ( is ) ;
305
+ runPostProcess ( inputString ) {
306
+ inputString = DefaultMode . runPostProcess ( inputString ) ;
307
307
/*
308
308
* This changes key names in titles to follow
309
309
* the English classical music guidelines.
310
310
* See https://musicbrainz.org/doc/Style/Classical/Language/English#Keys
311
311
*/
312
- is = is . replace (
312
+ inputString = inputString . replace (
313
313
/ \b i n ( [ a - g ] ) (?: [ \s - ] ( [ F f ] l a t | [ S s ] h a r p ) ) ? \s ( d o r i a n | l y d i a n | m a j o r | m i n o r | m i x o l y d i a n ) (?: \b | $ ) / ig,
314
314
function ( match , p1 , p2 , p3 ) {
315
315
return 'in ' + p1 . toUpperCase ( ) +
316
316
( p2 ? '-' + p2 . toLowerCase ( ) : '' ) +
317
317
' ' + p3 . toLowerCase ( ) ;
318
318
} ,
319
319
) ;
320
- return is ;
320
+ return inputString ;
321
321
} ,
322
322
} ;
323
323
@@ -335,8 +335,8 @@ export const French = {
335
335
336
336
name : 'French' ,
337
337
338
- runPostProcess ( is ) {
339
- return DefaultMode . runPostProcess ( is )
338
+ runPostProcess ( inputString ) {
339
+ return DefaultMode . runPostProcess ( inputString )
340
340
. replace ( / ( [ ! \? ; : ] + ) / gi, ' $1' )
341
341
. replace ( / ( [ « ] + ) / gi, '$1 ' )
342
342
. replace ( / ( [ » ] + ) / gi, ' $1' )
@@ -374,8 +374,8 @@ export const Turkish = {
374
374
} ,
375
375
) ) ,
376
376
377
- isLowerCaseWord ( w ) {
378
- return LOWER_CASE_WORDS . test ( w ) || LOWER_CASE_WORDS_TURKISH . test ( w ) ;
377
+ isLowerCaseWord ( word ) {
378
+ return LOWER_CASE_WORDS . test ( word ) || LOWER_CASE_WORDS_TURKISH . test ( word ) ;
379
379
} ,
380
380
381
381
isSentenceCaps ( ) {
0 commit comments