@@ -73,6 +73,7 @@ for (var n = 0; n < GLOBAL_OBJECT_PROPERTIES.length; n++) {
7373  GLOBAL_OBJECT_PROPERTY_MAP [ GLOBAL_OBJECT_PROPERTIES [ n ] ]  = 
7474    GLOBAL_OBJECT_PROPERTIES [ n ] ; 
7575} 
76+ const  kBufferedCommandSymbol  =  Symbol ( 'bufferedCommand' ) ; 
7677
7778try  { 
7879  // hack for require.resolve("./relative") to work properly. 
@@ -300,7 +301,7 @@ function REPLServer(prompt,
300301    }  else  { 
301302      top . outputStream . write ( `Thrown: ${ String ( e ) }  ) ; 
302303    } 
303-     top . bufferedCommand   =   '' ; 
304+     top . clearBufferedCommand ( ) ; 
304305    top . lines . level  =  [ ] ; 
305306    top . displayPrompt ( ) ; 
306307  } ) ; 
@@ -326,9 +327,17 @@ function REPLServer(prompt,
326327  self . outputStream  =  output ; 
327328
328329  self . resetContext ( ) ; 
329-   self . bufferedCommand  =  '' ; 
330330  self . lines . level  =  [ ] ; 
331331
332+   self . clearBufferedCommand ( ) ; 
333+   Object . defineProperty ( this ,  'bufferedCommand' ,  { 
334+     get : util . deprecate ( ( )  =>  self [ kBufferedCommandSymbol ] , 
335+                         'REPLServer.bufferedCommand is deprecated' ,  'DEP0074' ) , 
336+     set : util . deprecate ( ( val )  =>  self [ kBufferedCommandSymbol ]  =  val , 
337+                         'REPLServer.bufferedCommand is deprecated' ,  'DEP0074' ) , 
338+     enumerable : true 
339+   } ) ; 
340+ 
332341  // Figure out which "complete" function to use. 
333342  self . completer  =  ( typeof  options . completer  ===  'function' )  ?
334343    options . completer  : completer ; 
@@ -376,7 +385,8 @@ function REPLServer(prompt,
376385    self . clearLine ( ) ; 
377386    self . turnOffEditorMode ( ) ; 
378387
379-     if  ( ! ( self . bufferedCommand  &&  self . bufferedCommand . length  >  0 )  &&  empty )  { 
388+     const  cmd  =  self [ kBufferedCommandSymbol ] ; 
389+     if  ( ! ( cmd  &&  cmd . length  >  0 )  &&  empty )  { 
380390      if  ( sawSIGINT )  { 
381391        self . close ( ) ; 
382392        sawSIGINT  =  false ; 
@@ -388,7 +398,7 @@ function REPLServer(prompt,
388398      sawSIGINT  =  false ; 
389399    } 
390400
391-     self . bufferedCommand   =   '' ; 
401+     self . clearBufferedCommand ( ) ; 
392402    self . lines . level  =  [ ] ; 
393403    self . displayPrompt ( ) ; 
394404  } ) ; 
@@ -399,7 +409,7 @@ function REPLServer(prompt,
399409    sawSIGINT  =  false ; 
400410
401411    if  ( self . editorMode )  { 
402-       self . bufferedCommand  +=  cmd  +  '\n' ; 
412+       self [ kBufferedCommandSymbol ]  +=  cmd  +  '\n' ; 
403413
404414      // code alignment 
405415      const  matches  =  self . _sawKeyPress  ? cmd . match ( / ^ \s + / )  : null ; 
@@ -427,15 +437,15 @@ function REPLServer(prompt,
427437        if  ( self . parseREPLKeyword ( keyword ,  rest )  ===  true )  { 
428438          return ; 
429439        } 
430-         if  ( ! self . bufferedCommand )  { 
440+         if  ( ! self [ kBufferedCommandSymbol ] )  { 
431441          self . outputStream . write ( 'Invalid REPL keyword\n' ) ; 
432442          finish ( null ) ; 
433443          return ; 
434444        } 
435445      } 
436446    } 
437447
438-     const  evalCmd  =  self . bufferedCommand  +  cmd  +  '\n' ; 
448+     const  evalCmd  =  self [ kBufferedCommandSymbol ]  +  cmd  +  '\n' ; 
439449
440450    debug ( 'eval %j' ,  evalCmd ) ; 
441451    self . eval ( evalCmd ,  self . context ,  'repl' ,  finish ) ; 
@@ -444,11 +454,11 @@ function REPLServer(prompt,
444454      debug ( 'finish' ,  e ,  ret ) ; 
445455      self . memory ( cmd ) ; 
446456
447-       if  ( e  &&  ! self . bufferedCommand  &&  cmd . trim ( ) . startsWith ( 'npm ' ) )  { 
457+       if  ( e  &&  ! self [ kBufferedCommandSymbol ]  &&  cmd . trim ( ) . startsWith ( 'npm ' ) )  { 
448458        self . outputStream . write ( 'npm should be run outside of the '  + 
449459                                'node repl, in your normal shell.\n'  + 
450460                                '(Press Control-D to exit.)\n' ) ; 
451-         self . bufferedCommand   =   '' ; 
461+         self . clearBufferedCommand ( ) ; 
452462        self . displayPrompt ( ) ; 
453463        return ; 
454464      } 
@@ -460,7 +470,7 @@ function REPLServer(prompt,
460470          // { 
461471          // ...  x: 1 
462472          // ...  } 
463-           self . bufferedCommand  +=  cmd  +  '\n' ; 
473+           self [ kBufferedCommandSymbol ]  +=  cmd  +  '\n' ; 
464474          self . displayPrompt ( ) ; 
465475          return ; 
466476        }  else  { 
@@ -469,7 +479,7 @@ function REPLServer(prompt,
469479      } 
470480
471481      // Clear buffer if no SyntaxErrors 
472-       self . bufferedCommand   =   '' ; 
482+       self . clearBufferedCommand ( ) ; 
473483      sawCtrlD  =  false ; 
474484
475485      // If we got any output - print it (if no error) 
@@ -495,7 +505,7 @@ function REPLServer(prompt,
495505      self . outputStream . write ( `${ self . _initialPrompt }  ) ; 
496506      self . outputStream . write ( 
497507        '// Entering editor mode (^D to finish, ^C to cancel)\n' ) ; 
498-       self . outputStream . write ( `${ self . bufferedCommand }  ) ; 
508+       self . outputStream . write ( `${ self [ kBufferedCommandSymbol ] }  ) ; 
499509      self . prompt ( true ) ; 
500510    }  else  { 
501511      self . displayPrompt ( true ) ; 
@@ -569,6 +579,10 @@ exports.start = function(prompt,
569579  return  repl ; 
570580} ; 
571581
582+ REPLServer . prototype . clearBufferedCommand  =  function  clearBufferedCommand ( )  { 
583+   this [ kBufferedCommandSymbol ]  =  '' ; 
584+ } ; 
585+ 
572586REPLServer . prototype . close  =  function  close ( )  { 
573587  if  ( this . terminal  &&  this . _flushing  &&  ! this . _closingOnFlush )  { 
574588    this . _closingOnFlush  =  true ; 
@@ -647,7 +661,7 @@ REPLServer.prototype.resetContext = function() {
647661
648662REPLServer . prototype . displayPrompt  =  function ( preserveCursor )  { 
649663  var  prompt  =  this . _initialPrompt ; 
650-   if  ( this . bufferedCommand . length )  { 
664+   if  ( this [ kBufferedCommandSymbol ] . length )  { 
651665    prompt  =  '...' ; 
652666    const  len  =  this . lines . level . length  ? this . lines . level . length  -  1  : 0 ; 
653667    const  levelInd  =  '..' . repeat ( len ) ; 
@@ -742,7 +756,8 @@ REPLServer.prototype.complete = function() {
742756// getter code. 
743757function  complete ( line ,  callback )  { 
744758  // There may be local variables to evaluate, try a nested REPL 
745-   if  ( this . bufferedCommand  !==  undefined  &&  this . bufferedCommand . length )  { 
759+   if  ( this [ kBufferedCommandSymbol ]  !==  undefined  && 
760+       this [ kBufferedCommandSymbol ] . length )  { 
746761    // Get a new array of inputted lines 
747762    var  tmp  =  this . lines . slice ( ) ; 
748763    // Kill off all function declarations to push all local variables into 
@@ -759,7 +774,7 @@ function complete(line, callback) {
759774    flat . run ( tmp ) ;                         // eval the flattened code 
760775    // all this is only profitable if the nested REPL 
761776    // does not have a bufferedCommand 
762-     if  ( ! magic . bufferedCommand )  { 
777+     if  ( ! magic [ kBufferedCommandSymbol ] )  { 
763778      return  magic . complete ( line ,  callback ) ; 
764779    } 
765780  } 
@@ -1172,7 +1187,7 @@ function defineDefaultCommands(repl) {
11721187  repl . defineCommand ( 'break' ,  { 
11731188    help : 'Sometimes you get stuck, this gets you out' , 
11741189    action : function ( )  { 
1175-       this . bufferedCommand   =   '' ; 
1190+       this . clearBufferedCommand ( ) ; 
11761191      this . displayPrompt ( ) ; 
11771192    } 
11781193  } ) ; 
@@ -1186,7 +1201,7 @@ function defineDefaultCommands(repl) {
11861201  repl . defineCommand ( 'clear' ,  { 
11871202    help : clearMessage , 
11881203    action : function ( )  { 
1189-       this . bufferedCommand   =   '' ; 
1204+       this . clearBufferedCommand ( ) ; 
11901205      if  ( ! this . useGlobal )  { 
11911206        this . outputStream . write ( 'Clearing context...\n' ) ; 
11921207        this . resetContext ( ) ; 
0 commit comments