@@ -675,7 +675,7 @@ function REPLServer(prompt,
675675 let matched = false ;
676676
677677 errStack = '' ;
678- for ( const line of lines ) {
678+ ArrayPrototypeForEach ( lines , ( line ) => {
679679 if ( ! matched &&
680680 RegExpPrototypeTest ( / ^ \[ ? ( [ A - Z ] [ a - z 0 - 9 _ ] * ) * E r r o r / , line ) ) {
681681 errStack += writer . options . breakLength >= line . length ?
@@ -685,7 +685,7 @@ function REPLServer(prompt,
685685 } else {
686686 errStack += line ;
687687 }
688- }
688+ } ) ;
689689 if ( ! matched ) {
690690 const ln = lines . length === 1 ? ' ' : ':\n' ;
691691 errStack = `Uncaught${ ln } ${ errStack } ` ;
@@ -780,9 +780,7 @@ function REPLServer(prompt,
780780 const prioritizedSigintQueue = new SafeSet ( ) ;
781781 self . on ( 'SIGINT' , function onSigInt ( ) {
782782 if ( prioritizedSigintQueue . size > 0 ) {
783- for ( const task of prioritizedSigintQueue ) {
784- task ( ) ;
785- }
783+ ArrayPrototypeForEach ( prioritizedSigintQueue , ( task ) => task ( ) ) ;
786784 return ;
787785 }
788786
@@ -1265,7 +1263,7 @@ function complete(line, callback) {
12651263 paths = ArrayPrototypeConcat ( module . paths , CJSModule . globalPaths ) ;
12661264 }
12671265
1268- for ( let dir of paths ) {
1266+ ArrayPrototypeForEach ( paths , ( dir ) => {
12691267 dir = path . resolve ( dir , subdir ) ;
12701268 const dirents = gracefulReaddir ( dir , { withFileTypes : true } ) || [ ] ;
12711269 for ( const dirent of dirents ) {
@@ -1293,7 +1291,7 @@ function complete(line, callback) {
12931291 }
12941292 }
12951293 }
1296- }
1294+ } ) ;
12971295 if ( group . length ) {
12981296 ArrayPrototypePush ( completionGroups , group ) ;
12991297 }
@@ -1303,7 +1301,7 @@ function complete(line, callback) {
13031301 }
13041302 } else if ( RegExpPrototypeTest ( fsAutoCompleteRE , line ) &&
13051303 this . allowBlockingCompletions ) {
1306- [ completionGroups , completeOn ] = completeFSFunctions ( line ) ;
1304+ ( { 0 : completionGroups , 1 : completeOn } = completeFSFunctions ( line ) ) ;
13071305 // Handle variable member lookup.
13081306 // We support simple chained expressions like the following (no function
13091307 // calls, etc.). That is for simplicity and also because we *eval* that
@@ -1316,7 +1314,7 @@ function complete(line, callback) {
13161314 // foo.<|> # completions for 'foo' with filter ''
13171315 } else if ( line . length === 0 ||
13181316 RegExpPrototypeTest ( / \w | \. | \$ / , line [ line . length - 1 ] ) ) {
1319- const [ match ] = RegExpPrototypeExec ( simpleExpressionRE , line ) || [ '' ] ;
1317+ const { 0 : match } = RegExpPrototypeExec ( simpleExpressionRE , line ) || [ '' ] ;
13201318 if ( line . length !== 0 && ! match ) {
13211319 completionGroupsLoaded ( ) ;
13221320 return ;
@@ -1386,11 +1384,11 @@ function complete(line, callback) {
13861384
13871385 if ( memberGroups . length ) {
13881386 expr += chaining ;
1389- for ( const group of memberGroups ) {
1387+ ArrayPrototypeForEach ( memberGroups , ( group ) => {
13901388 ArrayPrototypePush ( completionGroups ,
13911389 ArrayPrototypeMap ( group ,
13921390 ( member ) => `${ expr } ${ member } ` ) ) ;
1393- }
1391+ } ) ;
13941392 if ( filter ) {
13951393 filter = `${ expr } ${ filter } ` ;
13961394 }
@@ -1409,37 +1407,38 @@ function complete(line, callback) {
14091407 // Filter, sort (within each group), uniq and merge the completion groups.
14101408 if ( completionGroups . length && filter ) {
14111409 const newCompletionGroups = [ ] ;
1412- for ( const group of completionGroups ) {
1410+ ArrayPrototypeForEach ( completionGroups , ( group ) => {
14131411 const filteredGroup = ArrayPrototypeFilter (
14141412 group ,
14151413 ( str ) => StringPrototypeStartsWith ( str , filter )
14161414 ) ;
14171415 if ( filteredGroup . length ) {
14181416 ArrayPrototypePush ( newCompletionGroups , filteredGroup ) ;
14191417 }
1420- }
1418+ } ) ;
14211419 completionGroups = newCompletionGroups ;
14221420 }
14231421
14241422 const completions = [ ] ;
14251423 // Unique completions across all groups.
1426- const uniqueSet = new SafeSet ( [ '' ] ) ;
1424+ const uniqueSet = new SafeSet ( ) ;
1425+ uniqueSet . add ( '' ) ;
14271426 // Completion group 0 is the "closest" (least far up the inheritance
14281427 // chain) so we put its completions last: to be closest in the REPL.
1429- for ( const group of completionGroups ) {
1428+ ArrayPrototypeForEach ( completionGroups , ( group ) => {
14301429 ArrayPrototypeSort ( group , ( a , b ) => ( b > a ? 1 : - 1 ) ) ;
14311430 const setSize = uniqueSet . size ;
1432- for ( const entry of group ) {
1431+ ArrayPrototypeForEach ( group , ( entry ) => {
14331432 if ( ! uniqueSet . has ( entry ) ) {
14341433 ArrayPrototypeUnshift ( completions , entry ) ;
14351434 uniqueSet . add ( entry ) ;
14361435 }
1437- }
1436+ } ) ;
14381437 // Add a separator between groups.
14391438 if ( uniqueSet . size !== setSize ) {
14401439 ArrayPrototypeUnshift ( completions , '' ) ;
14411440 }
1442- }
1441+ } ) ;
14431442
14441443 // Remove obsolete group entry, if present.
14451444 if ( completions [ 0 ] === '' ) {
@@ -1608,14 +1607,13 @@ function defineDefaultCommands(repl) {
16081607 const longestNameLength = MathMax (
16091608 ...ArrayPrototypeMap ( names , ( name ) => name . length )
16101609 ) ;
1611- for ( let n = 0 ; n < names . length ; n ++ ) {
1612- const name = names [ n ] ;
1610+ ArrayPrototypeForEach ( names , ( name ) => {
16131611 const cmd = this . commands [ name ] ;
16141612 const spaces =
16151613 StringPrototypeRepeat ( ' ' , longestNameLength - name . length + 3 ) ;
16161614 const line = `.${ name } ${ cmd . help ? spaces + cmd . help : '' } \n` ;
16171615 this . output . write ( line ) ;
1618- }
1616+ } ) ;
16191617 this . output . write ( '\nPress Ctrl+C to abort current expression, ' +
16201618 'Ctrl+D to exit the REPL\n' ) ;
16211619 this . displayPrompt ( ) ;
0 commit comments