repl: make REPLServer inherit from EventEmitter

This is because it should emit an "exit" event when "SIGINT" is received
from the readline interface, or when ".exit" is typed by the user.
pull/24503/head
Nathan Rajlich 2012-03-12 17:25:51 -07:00 committed by Bert Belder
parent 109b16d488
commit 4f63f9f327
1 changed files with 5 additions and 0 deletions

View File

@ -41,10 +41,12 @@
*/
var util = require('util');
var inherits = require('util').inherits;
var vm = require('vm');
var path = require('path');
var fs = require('fs');
var rl = require('readline');
var EventEmitter = require('events').EventEmitter;
// If obj.hasOwnProperty has been overridden, then calling
// obj.hasOwnProperty(prop) will break.
@ -74,6 +76,8 @@ var builtinLibs = ['assert', 'buffer', 'child_process', 'cluster',
function REPLServer(prompt, stream, eval, useGlobal, ignoreUndefined) {
EventEmitter.call(this);
var self = this;
self.useGlobal = useGlobal;
@ -264,6 +268,7 @@ function REPLServer(prompt, stream, eval, useGlobal, ignoreUndefined) {
self.displayPrompt();
}
inherits(REPLServer, EventEmitter);
exports.REPLServer = REPLServer;