Skip to content

Commit

Permalink
lib,src: remove usage of events.EventEmitter
Browse files Browse the repository at this point in the history
The `events` module already exports `EventEmitter` constructor function
So, we don't have to use `events.EventEmitter` to access it.

Refer: #2896

PR-URL: #2921
Reviewed-By: Roman Reiss <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
  • Loading branch information
thefourtheye committed Sep 22, 2015
1 parent 7953c83 commit f32a606
Show file tree
Hide file tree
Showing 15 changed files with 23 additions and 22 deletions.
2 changes: 1 addition & 1 deletion lib/_http_agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion lib/_http_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
5 changes: 3 additions & 2 deletions lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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) }
Expand Down
2 changes: 1 addition & 1 deletion lib/_stream_readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
6 changes: 3 additions & 3 deletions lib/_tls_legacy.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion lib/cluster.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
6 changes: 3 additions & 3 deletions lib/dgram.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;


Expand Down
2 changes: 1 addition & 1 deletion lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion lib/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/socket_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions lib/net.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;


Expand Down
2 changes: 1 addition & 1 deletion lib/readline.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion lib/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module.exports = Stream;

const EE = require('events').EventEmitter;
const EE = require('events');
const util = require('util');

util.inherits(Stream, EE);
Expand Down
2 changes: 1 addition & 1 deletion src/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit f32a606

Please sign in to comment.