@@ -320,15 +320,10 @@ function REPLServer(prompt,
320320// Use stdin and stdout as the default streams if none were given
321321stream = process ;
322322}
323- if ( stream . stdin && stream . stdout ) {
324- // We're given custom object with 2 streams, or the `process` object
325- input = stream . stdin ;
326- output = stream . stdout ;
327- } else {
328- // We're given a duplex readable/writable Stream, like a `net.Socket`
329- input = stream ;
330- output = stream ;
331- }
323+ // We're given a duplex readable/writable Stream, like a `net.Socket`
324+ // or a custom object with 2 streams, or the `process` object
325+ input = stream . stdin || stream ;
326+ output = stream . stdout || stream ;
332327}
333328
334329self . inputStream = input ;
@@ -663,7 +658,7 @@ REPLServer.prototype.createContext = function(){
663658Object . defineProperty ( context , 'console' , {
664659configurable : true ,
665660enumerable : true ,
666- get : ( ) => _console
661+ value : _console
667662} ) ;
668663
669664var names = Object . getOwnPropertyNames ( global ) ;
@@ -1035,19 +1030,16 @@ function complete(line, callback){
10351030break ;
10361031}
10371032}
1038- } catch ( e ) {
1039- // console.log("completion error walking prototype chain:" + e);
1040- }
1033+ } catch ( e ) { }
10411034}
10421035
10431036if ( memberGroups . length ) {
10441037for ( i = 0 ; i < memberGroups . length ; i ++ ) {
1045- completionGroups . push ( memberGroups [ i ] . map ( function ( member ) {
1046- return expr + '.' + member ;
1047- } ) ) ;
1038+ completionGroups . push (
1039+ memberGroups [ i ] . map ( ( member ) => `${ expr } .${ member } ` ) ) ;
10481040}
10491041if ( filter ) {
1050- filter = expr + '.' + filter ;
1042+ filter = ` ${ expr } . ${ filter } ` ;
10511043}
10521044}
10531045
@@ -1068,9 +1060,8 @@ function complete(line, callback){
10681060if ( completionGroups . length && filter ) {
10691061var newCompletionGroups = [ ] ;
10701062for ( i = 0 ; i < completionGroups . length ; i ++ ) {
1071- group = completionGroups [ i ] . filter ( function ( elem ) {
1072- return elem . indexOf ( filter ) === 0 ;
1073- } ) ;
1063+ group = completionGroups [ i ]
1064+ . filter ( ( elem ) => elem . indexOf ( filter ) === 0 ) ;
10741065if ( group . length ) {
10751066newCompletionGroups . push ( group ) ;
10761067}
@@ -1400,55 +1391,33 @@ function isCodeRecoverable(code){
14001391
14011392if ( previous === '\\' && ( stringLiteral || isRegExpLiteral ) ) {
14021393current = null ;
1403- continue ;
1404- }
1405-
1406- if ( stringLiteral ) {
1394+ } else if ( stringLiteral ) {
14071395if ( stringLiteral === current ) {
14081396stringLiteral = null ;
14091397}
1410- continue ;
1411- } else {
1412- if ( isRegExpLiteral && current === '/' ) {
1413- isRegExpLiteral = false ;
1414- continue ;
1415- }
1416-
1417- if ( isBlockComment && previous === '*' && current === '/' ) {
1418- isBlockComment = false ;
1419- continue ;
1420- }
1421-
1422- if ( isSingleComment && current === '\n' ) {
1423- isSingleComment = false ;
1424- continue ;
1425- }
1426-
1427- if ( isBlockComment || isRegExpLiteral || isSingleComment ) continue ;
1428-
1398+ } else if ( isRegExpLiteral && current === '/' ) {
1399+ isRegExpLiteral = false ;
1400+ } else if ( isBlockComment && previous === '*' && current === '/' ) {
1401+ isBlockComment = false ;
1402+ } else if ( isSingleComment && current === '\n' ) {
1403+ isSingleComment = false ;
1404+ } else if ( ! isBlockComment && ! isRegExpLiteral && ! isSingleComment ) {
14291405if ( current === '/' && previous === '/' ) {
14301406isSingleComment = true ;
1431- continue ;
1432- }
1433-
1434- if ( previous === '/' ) {
1407+ } else if ( previous === '/' ) {
14351408if ( current === '*' ) {
14361409isBlockComment = true ;
1437- } else if (
14381410// Distinguish between a division operator and the start of a regex
14391411// by examining the non-whitespace character that precedes the /
1440- [ null , '(' , '[' , '{' , '}' , '' ] . includes ( prevTokenChar )
1441- ) {
1412+ } else if ( [ null , '(' , '[' , '{' , '}' , '' ] . includes ( prevTokenChar ) ) {
14421413isRegExpLiteral = true ;
14431414}
1444- continue ;
1415+ } else {
1416+ if ( current . trim ( ) ) prevTokenChar = current ;
1417+ if ( current === '\'' || current === '"' ) {
1418+ stringLiteral = current ;
1419+ }
14451420}
1446-
1447- if ( current . trim ( ) ) prevTokenChar = current ;
1448- }
1449-
1450- if ( current === '\'' || current === '"' ) {
1451- stringLiteral = current ;
14521421}
14531422}
14541423
0 commit comments