Browse Source

lib,src: remove usage of events.EventEmitter

The `events` module already exports `EventEmitter` constructor function
So, we don't have to use `events.EventEmitter` to access it.

Refer: https://github.com/nodejs/node/pull/2896

PR-URL: https://github.com/nodejs/node/pull/2921
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
v4.x
Sakthipriyan Vairamani 9 years ago
committed by Rod Vagg
parent
commit
1860e0cebd
  1. 2
      lib/_http_agent.js
  2. 2
      lib/_http_client.js
  3. 5
      lib/_http_server.js
  4. 2
      lib/_stream_readable.js
  5. 6
      lib/_tls_legacy.js
  6. 2
      lib/cluster.js
  7. 6
      lib/dgram.js
  8. 2
      lib/fs.js
  9. 2
      lib/http.js
  10. 2
      lib/internal/child_process.js
  11. 2
      lib/internal/socket_list.js
  12. 6
      lib/net.js
  13. 2
      lib/readline.js
  14. 2
      lib/stream.js
  15. 2
      src/node.js

2
lib/_http_agent.js

@ -2,7 +2,7 @@
const net = require('net');
const util = require('util');
const EventEmitter = require('events').EventEmitter;
const EventEmitter = require('events');
const debug = util.debuglog('http');
// New Agent code.

2
lib/_http_client.js

@ -3,7 +3,7 @@
const util = require('util');
const net = require('net');
const url = require('url');
const EventEmitter = require('events').EventEmitter;
const EventEmitter = require('events');
const HTTPParser = process.binding('http_parser').HTTPParser;
const assert = require('assert').ok;
const common = require('_http_common');

5
lib/_http_server.js

@ -2,7 +2,7 @@
const util = require('util');
const net = require('net');
const EventEmitter = require('events').EventEmitter;
const EventEmitter = require('events');
const HTTPParser = process.binding('http_parser').HTTPParser;
const assert = require('assert').ok;
const common = require('_http_common');
@ -117,7 +117,8 @@ function onServerResponseClose() {
// array. That is, in the example below, b still gets called even though
// it's been removed by a:
//
// var obj = new events.EventEmitter;
// var EventEmitter = require('events');
// var obj = new EventEmitter();
// obj.on('event', a);
// obj.on('event', b);
// function a() { obj.removeListener('event', b) }

2
lib/_stream_readable.js

@ -3,7 +3,7 @@
module.exports = Readable;
Readable.ReadableState = ReadableState;
const EE = require('events').EventEmitter;
const EE = require('events');
const Stream = require('stream');
const Buffer = require('buffer').Buffer;
const util = require('util');

6
lib/_tls_legacy.js

@ -1,7 +1,7 @@
'use strict';
const assert = require('assert');
const events = require('events');
const EventEmitter = require('events');
const stream = require('stream');
const tls = require('tls');
const util = require('util');
@ -672,7 +672,7 @@ function SecurePair(context, isServer, requestCert, rejectUnauthorized,
options || (options = {});
events.EventEmitter.call(this);
EventEmitter.call(this);
this.server = options.server;
this._secureEstablished = false;
@ -741,7 +741,7 @@ function SecurePair(context, isServer, requestCert, rejectUnauthorized,
process.nextTick(securePairNT, this, options);
}
util.inherits(SecurePair, events.EventEmitter);
util.inherits(SecurePair, EventEmitter);
function securePairNT(self, options) {
/* The Connection may be destroyed by an abort call */

2
lib/cluster.js

@ -1,6 +1,6 @@
'use strict';
const EventEmitter = require('events').EventEmitter;
const EventEmitter = require('events');
const assert = require('assert');
const dgram = require('dgram');
const fork = require('child_process').fork;

6
lib/dgram.js

@ -3,7 +3,7 @@
const assert = require('assert');
const Buffer = require('buffer').Buffer;
const util = require('util');
const events = require('events');
const EventEmitter = require('events');
const constants = require('constants');
const UDP = process.binding('udp_wrap').UDP;
@ -79,7 +79,7 @@ exports._createSocketHandle = function(address, port, addressType, fd, flags) {
function Socket(type, listener) {
events.EventEmitter.call(this);
EventEmitter.call(this);
if (typeof type === 'object') {
var options = type;
@ -101,7 +101,7 @@ function Socket(type, listener) {
if (typeof listener === 'function')
this.on('message', listener);
}
util.inherits(Socket, events.EventEmitter);
util.inherits(Socket, EventEmitter);
exports.Socket = Socket;

2
lib/fs.js

@ -12,7 +12,7 @@ const constants = require('constants');
const fs = exports;
const Buffer = require('buffer').Buffer;
const Stream = require('stream').Stream;
const EventEmitter = require('events').EventEmitter;
const EventEmitter = require('events');
const FSReqWrap = binding.FSReqWrap;
const FSEvent = process.binding('fs_event_wrap').FSEvent;

2
lib/http.js

@ -2,7 +2,7 @@
const util = require('util');
const internalUtil = require('internal/util');
const EventEmitter = require('events').EventEmitter;
const EventEmitter = require('events');
exports.IncomingMessage = require('_http_incoming').IncomingMessage;

2
lib/internal/child_process.js

@ -2,7 +2,7 @@
const StringDecoder = require('string_decoder').StringDecoder;
const Buffer = require('buffer').Buffer;
const EventEmitter = require('events').EventEmitter;
const EventEmitter = require('events');
const net = require('net');
const dgram = require('dgram');
const util = require('util');

2
lib/internal/socket_list.js

@ -2,7 +2,7 @@
module.exports = {SocketListSend, SocketListReceive};
const EventEmitter = require('events').EventEmitter;
const EventEmitter = require('events');
const util = require('util');
// This object keep track of the socket there are sended

6
lib/net.js

@ -1,6 +1,6 @@
'use strict';
const events = require('events');
const EventEmitter = require('events');
const stream = require('stream');
const timers = require('timers');
const util = require('util');
@ -1071,7 +1071,7 @@ function Server(options, connectionListener) {
if (!(this instanceof Server))
return new Server(options, connectionListener);
events.EventEmitter.call(this);
EventEmitter.call(this);
var self = this;
var options;
@ -1113,7 +1113,7 @@ function Server(options, connectionListener) {
this.allowHalfOpen = options.allowHalfOpen || false;
this.pauseOnConnect = !!options.pauseOnConnect;
}
util.inherits(Server, events.EventEmitter);
util.inherits(Server, EventEmitter);
exports.Server = Server;

2
lib/readline.js

@ -12,7 +12,7 @@ const util = require('util');
const internalUtil = require('internal/util');
const inherits = util.inherits;
const Buffer = require('buffer').Buffer;
const EventEmitter = require('events').EventEmitter;
const EventEmitter = require('events');
exports.createInterface = function(input, output, completer, terminal) {

2
lib/stream.js

@ -2,7 +2,7 @@
module.exports = Stream;
const EE = require('events').EventEmitter;
const EE = require('events');
const util = require('util');
util.inherits(Stream, EE);

2
src/node.js

@ -10,7 +10,7 @@
this.global = this;
function startup() {
var EventEmitter = NativeModule.require('events').EventEmitter;
var EventEmitter = NativeModule.require('events');
process.__proto__ = Object.create(EventEmitter.prototype, {
constructor: {

Loading…
Cancel
Save