@@ -99,8 +99,6 @@ const registeredFlags = {
99
99
* @returns {RegExp } Augmented regex.
100
100
*/
101
101
function augment ( regex , captureNames , xSource , xFlags , isInternalOnly ) {
102
- let p ;
103
-
104
102
regex [ REGEX_DATA ] = {
105
103
captureNames
106
104
} ;
@@ -113,7 +111,7 @@ function augment(regex, captureNames, xSource, xFlags, isInternalOnly) {
113
111
if ( regex . __proto__ ) {
114
112
regex . __proto__ = XRegExp . prototype ;
115
113
} else {
116
- for ( p in XRegExp . prototype ) {
114
+ for ( const p in XRegExp . prototype ) {
117
115
// An `XRegExp.prototype.hasOwnProperty(p)` check wouldn't be worth it here, since this
118
116
// is performance sensitive, and enumerable `Object.prototype` or `RegExp.prototype`
119
117
// extensions exist on `regex.prototype` anyway
@@ -362,8 +360,6 @@ function pad4(str) {
362
360
* @returns {Object } Object with properties `pattern` and `flags`.
363
361
*/
364
362
function prepareFlags ( pattern , flags ) {
365
- let i ;
366
-
367
363
// Recent browsers throw on duplicate flags, so copy this behavior for nonnative flags
368
364
if ( clipDuplicates ( flags ) !== flags ) {
369
365
throw new SyntaxError ( `Invalid duplicate regex flag ${ flags } ` ) ;
@@ -380,7 +376,7 @@ function prepareFlags(pattern, flags) {
380
376
} ) ;
381
377
382
378
// Throw on unknown native or nonnative flags
383
- for ( i = 0 ; i < flags . length ; ++ i ) {
379
+ for ( let i = 0 ; i < flags . length ; ++ i ) {
384
380
if ( ! registeredFlags [ flags [ i ] ] ) {
385
381
throw new SyntaxError ( `Unknown regex flag ${ flags [ i ] } ` ) ;
386
382
}
@@ -717,16 +713,15 @@ XRegExp._pad4 = pad4;
717
713
*/
718
714
XRegExp . addToken = ( regex , handler , options ) => {
719
715
options = options || { } ;
720
- let optionalFlags = options . optionalFlags ;
721
- let i ;
716
+ let { optionalFlags} = options ;
722
717
723
718
if ( options . flag ) {
724
719
registerFlag ( options . flag ) ;
725
720
}
726
721
727
722
if ( optionalFlags ) {
728
723
optionalFlags = nativ . split . call ( optionalFlags , '' ) ;
729
- for ( i = 0 ; i < optionalFlags . length ; ++ i ) {
724
+ for ( let i = 0 ; i < optionalFlags . length ; ++ i ) {
730
725
registerFlag ( optionalFlags [ i ] ) ;
731
726
}
732
727
}
@@ -1217,11 +1212,8 @@ XRegExp.replace = (str, search, replacement, scope) => {
1217
1212
* ]);
1218
1213
*/
1219
1214
XRegExp . replaceEach = ( str , replacements ) => {
1220
- let i ;
1221
- let r ;
1222
-
1223
- for ( i = 0 ; i < replacements . length ; ++ i ) {
1224
- r = replacements [ i ] ;
1215
+ for ( let i = 0 ; i < replacements . length ; ++ i ) {
1216
+ const r = replacements [ i ] ;
1225
1217
str = XRegExp . replace ( str , r [ 0 ] , r [ 1 ] , r [ 2 ] ) ;
1226
1218
}
1227
1219
@@ -1367,9 +1359,8 @@ XRegExp.union = (patterns, flags, options) => {
1367
1359
1368
1360
const parts = / ( \( ) (? ! \? ) | \\ ( [ 1 - 9 ] \d * ) | \\ [ \s \S ] | \[ (?: [ ^ \\ \] ] | \\ [ \s \S ] ) * \] / g;
1369
1361
const output = [ ] ;
1370
- let pattern ;
1371
1362
for ( let i = 0 ; i < patterns . length ; ++ i ) {
1372
- pattern = patterns [ i ] ;
1363
+ const pattern = patterns [ i ] ;
1373
1364
1374
1365
if ( XRegExp . isRegExp ( pattern ) ) {
1375
1366
numPriorCaptures = numCaptures ;
0 commit comments