@@ -1142,15 +1142,14 @@ function complete(line, callback) {
1142
1142
paths = module . paths . concat ( CJSModule . globalPaths ) ;
1143
1143
}
1144
1144
1145
- for ( let i = 0 ; i < paths . length ; i ++ ) {
1146
- dir = path . resolve ( paths [ i ] , subdir ) ;
1145
+ for ( const pathEntry of paths ) {
1146
+ dir = path . resolve ( pathEntry , subdir ) ;
1147
1147
try {
1148
1148
files = fs . readdirSync ( dir ) ;
1149
1149
} catch {
1150
1150
continue ;
1151
1151
}
1152
- for ( let f = 0 ; f < files . length ; f ++ ) {
1153
- const name = files [ f ] ;
1152
+ for ( const name of files ) {
1154
1153
const ext = path . extname ( name ) ;
1155
1154
const base = name . slice ( 0 , - ext . length ) ;
1156
1155
if ( versionedFileNamesRe . test ( base ) || name === '.npm' ) {
@@ -1170,8 +1169,8 @@ function complete(line, callback) {
1170
1169
} catch {
1171
1170
continue ;
1172
1171
}
1173
- for ( let s = 0 ; s < subfiles . length ; s ++ ) {
1174
- if ( indexRe . test ( subfiles [ s ] ) ) {
1172
+ for ( const subfile of subfiles ) {
1173
+ if ( indexRe . test ( subfile ) ) {
1175
1174
group . push ( subdir + name ) ;
1176
1175
}
1177
1176
}
@@ -1295,9 +1294,9 @@ function complete(line, callback) {
1295
1294
}
1296
1295
1297
1296
if ( memberGroups . length ) {
1298
- for ( let i = 0 ; i < memberGroups . length ; i ++ ) {
1297
+ for ( const memberGroup of memberGroups ) {
1299
1298
completionGroups . push (
1300
- memberGroups [ i ] . map ( ( member ) => `${ expr } .${ member } ` ) ) ;
1299
+ memberGroup . map ( ( member ) => `${ expr } .${ member } ` ) ) ;
1301
1300
}
1302
1301
if ( filter ) {
1303
1302
filter = `${ expr } .${ filter } ` ;
@@ -1316,8 +1315,8 @@ function complete(line, callback) {
1316
1315
// Filter, sort (within each group), uniq and merge the completion groups.
1317
1316
if ( completionGroups . length && filter ) {
1318
1317
const newCompletionGroups = [ ] ;
1319
- for ( let i = 0 ; i < completionGroups . length ; i ++ ) {
1320
- group = completionGroups [ i ]
1318
+ for ( const completionGroup of completionGroups ) {
1319
+ group = completionGroup
1321
1320
. filter ( ( elem ) => elem . indexOf ( filter ) === 0 ) ;
1322
1321
if ( group . length ) {
1323
1322
newCompletionGroups . push ( group ) ;
@@ -1516,8 +1515,7 @@ function defineDefaultCommands(repl) {
1516
1515
( max , name ) => MathMax ( max , name . length ) ,
1517
1516
0
1518
1517
) ;
1519
- for ( let n = 0 ; n < names . length ; n ++ ) {
1520
- const name = names [ n ] ;
1518
+ for ( const name of names ) {
1521
1519
const cmd = this . commands [ name ] ;
1522
1520
const spaces = ' ' . repeat ( longestNameLength - name . length + 3 ) ;
1523
1521
const line = `.${ name } ${ cmd . help ? spaces + cmd . help : '' } \n` ;
0 commit comments