@@ -412,15 +412,10 @@ function REPLServer(prompt,
412
412
// Use stdin and stdout as the default streams if none were given
413
413
stream = process ;
414
414
}
415
- if ( stream . stdin && stream . stdout ) {
416
- // We're given custom object with 2 streams, or the `process` object
417
- input = stream . stdin ;
418
- output = stream . stdout ;
419
- } else {
420
- // We're given a duplex readable/writable Stream, like a `net.Socket`
421
- input = stream ;
422
- output = stream ;
423
- }
415
+ // We're given a duplex readable/writable Stream, like a `net.Socket`
416
+ // or a custom object with 2 streams, or the `process` object
417
+ input = stream . stdin || stream ;
418
+ output = stream . stdout || stream ;
424
419
}
425
420
426
421
self . inputStream = input ;
@@ -770,7 +765,7 @@ REPLServer.prototype.createContext = function() {
770
765
Object . defineProperty ( context , 'console' , {
771
766
configurable : true ,
772
767
enumerable : true ,
773
- get : ( ) => _console
768
+ value : _console
774
769
} ) ;
775
770
776
771
var names = Object . getOwnPropertyNames ( global ) ;
@@ -1129,19 +1124,16 @@ function complete(line, callback) {
1129
1124
break ;
1130
1125
}
1131
1126
}
1132
- } catch ( e ) {
1133
- // console.log("completion error walking prototype chain:" + e);
1134
- }
1127
+ } catch ( e ) { }
1135
1128
}
1136
1129
1137
1130
if ( memberGroups . length ) {
1138
1131
for ( i = 0 ; i < memberGroups . length ; i ++ ) {
1139
- completionGroups . push ( memberGroups [ i ] . map ( function ( member ) {
1140
- return expr + '.' + member ;
1141
- } ) ) ;
1132
+ completionGroups . push (
1133
+ memberGroups [ i ] . map ( ( member ) => `${ expr } .${ member } ` ) ) ;
1142
1134
}
1143
1135
if ( filter ) {
1144
- filter = expr + '.' + filter ;
1136
+ filter = ` ${ expr } . ${ filter } ` ;
1145
1137
}
1146
1138
}
1147
1139
@@ -1162,9 +1154,8 @@ function complete(line, callback) {
1162
1154
if ( completionGroups . length && filter ) {
1163
1155
var newCompletionGroups = [ ] ;
1164
1156
for ( i = 0 ; i < completionGroups . length ; i ++ ) {
1165
- group = completionGroups [ i ] . filter ( function ( elem ) {
1166
- return elem . indexOf ( filter ) === 0 ;
1167
- } ) ;
1157
+ group = completionGroups [ i ]
1158
+ . filter ( ( elem ) => elem . indexOf ( filter ) === 0 ) ;
1168
1159
if ( group . length ) {
1169
1160
newCompletionGroups . push ( group ) ;
1170
1161
}
@@ -1493,55 +1484,33 @@ function isCodeRecoverable(code) {
1493
1484
1494
1485
if ( previous === '\\' && ( stringLiteral || isRegExpLiteral ) ) {
1495
1486
current = null ;
1496
- continue ;
1497
- }
1498
-
1499
- if ( stringLiteral ) {
1487
+ } else if ( stringLiteral ) {
1500
1488
if ( stringLiteral === current ) {
1501
1489
stringLiteral = null ;
1502
1490
}
1503
- continue ;
1504
- } else {
1505
- if ( isRegExpLiteral && current === '/' ) {
1506
- isRegExpLiteral = false ;
1507
- continue ;
1508
- }
1509
-
1510
- if ( isBlockComment && previous === '*' && current === '/' ) {
1511
- isBlockComment = false ;
1512
- continue ;
1513
- }
1514
-
1515
- if ( isSingleComment && current === '\n' ) {
1516
- isSingleComment = false ;
1517
- continue ;
1518
- }
1519
-
1520
- if ( isBlockComment || isRegExpLiteral || isSingleComment ) continue ;
1521
-
1491
+ } else if ( isRegExpLiteral && current === '/' ) {
1492
+ isRegExpLiteral = false ;
1493
+ } else if ( isBlockComment && previous === '*' && current === '/' ) {
1494
+ isBlockComment = false ;
1495
+ } else if ( isSingleComment && current === '\n' ) {
1496
+ isSingleComment = false ;
1497
+ } else if ( ! isBlockComment && ! isRegExpLiteral && ! isSingleComment ) {
1522
1498
if ( current === '/' && previous === '/' ) {
1523
1499
isSingleComment = true ;
1524
- continue ;
1525
- }
1526
-
1527
- if ( previous === '/' ) {
1500
+ } else if ( previous === '/' ) {
1528
1501
if ( current === '*' ) {
1529
1502
isBlockComment = true ;
1530
- } else if (
1531
1503
// Distinguish between a division operator and the start of a regex
1532
1504
// by examining the non-whitespace character that precedes the /
1533
- [ null , '(' , '[' , '{' , '}' , ';' ] . includes ( prevTokenChar )
1534
- ) {
1505
+ } else if ( [ null , '(' , '[' , '{' , '}' , ';' ] . includes ( prevTokenChar ) ) {
1535
1506
isRegExpLiteral = true ;
1536
1507
}
1537
- continue ;
1508
+ } else {
1509
+ if ( current . trim ( ) ) prevTokenChar = current ;
1510
+ if ( current === '\'' || current === '"' ) {
1511
+ stringLiteral = current ;
1512
+ }
1538
1513
}
1539
-
1540
- if ( current . trim ( ) ) prevTokenChar = current ;
1541
- }
1542
-
1543
- if ( current === '\'' || current === '"' ) {
1544
- stringLiteral = current ;
1545
1514
}
1546
1515
}
1547
1516
0 commit comments