lib/ui.js
function UI (input, output) {
  this.rl = readline.createInterface({
    input: input || ttys.stdin,
    output: output || ttys.stdout
  })
  
  // Delegated events bind.
  this.onLine = (function onLine () {
    _events.line.apply(this, arguments)
  }).bind(this)
  
  this.onKeypress = (function onKeypress () {
    if (this.rl) {
      _events.keypress.apply(this, arguments)
    }
  }).bind(this)
  
  this.forceClose = this.forceClose.bind(this)
  
  this.rl.addListener('line', this.onLine)
  this.rl.input.addListener('keypress', this.onKeypress)
  
  this.rl.on('SIGINT', this.forceClose)
  process.on('exit', this.forceClose)
}
function UI (input, output) {
  this.rl = readline.createInterface({
    input: input || ttys.stdin,
    output: output || ttys.stdout
  })
  
  // Delegated events bind.
  this.onLine = (function onLine () {
    _events.line.apply(this, arguments)
  }).bind(this)
  
  this.onKeypress = (function onKeypress () {
    if (this.rl) {
      _events.keypress.apply(this, arguments)
    }
  }).bind(this)
  
  this.forceClose = this.forceClose.bind(this)
  
  this.rl.addListener('line', this.onLine)
  this.rl.input.addListener('keypress', this.onKeypress)
  
  this.rl.on('SIGINT', this.forceClose)
  process.on('exit', this.forceClose)
}
function UI ( input , output ) { this . rl = readline . createInterface ( { input : input || ttys . stdin , output : output || ttys . stdout } ) // Delegated events bind. this . onLine = ( function onLine ( ) { _events . line . apply ( this , arguments ) } ) . bind ( this ) this . onKeypress = ( function onKeypress ( ) { if ( this . rl ) { _events . keypress . apply ( this , arguments ) } } ) . bind ( this ) this . forceClose = this . forceClose . bind ( this ) this . rl . addListener ( 'line' , this . onLine ) this . rl . input . addListener ( 'keypress' , this . onKeypress ) this . rl . on ( 'SIGINT' , this . forceClose ) process . on ( 'exit' , this . forceClose ) }
UI constructor, to create ui to control IO.

@constructor
@param {Stream} [input]
@param {Stream} [output]
UI constructor to create ui to control IO .