Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib,src,doc: remove usage of events.EventEmitter #2921

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/api/errors.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -454,9 +454,9 @@ provided by Node.js -- even user created event emitters and streams will throw
errors when no error handlers are attached. An example:

```javascript
var events = require('events');
var EventEmitter = require('events');

var ee = new events.EventEmitter;
var ee = new EventEmitter();

setImmediate(function() {
// this will crash the process because no "error" event
Expand Down
2 changes: 1 addition & 1 deletion doc/api/events.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ constructor function. For example:

'use strict';
const util = require('util');
const EventEmitter = require('events').EventEmitter;
const EventEmitter = require('events');

function MyEventEmitter() {
// Initialize necessary properties from `EventEmitter` in this instance
Expand Down
2 changes: 1 addition & 1 deletion doc/api/modules.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ which is probably not what you want to do.

For example suppose we were making a module called `a.js`

var EventEmitter = require('events').EventEmitter;
var EventEmitter = require('events');

module.exports = new EventEmitter();

Expand Down
10 changes: 5 additions & 5 deletions doc/api/util.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -426,22 +426,22 @@ As an additional convenience, `superConstructor` will be accessible
through the `constructor.super_` property.

var util = require("util");
var events = require("events");
var EventEmitter = require("events");

function MyStream() {
events.EventEmitter.call(this);
EventEmitter.call(this);
}

util.inherits(MyStream, events.EventEmitter);
util.inherits(MyStream, EventEmitter);

MyStream.prototype.write = function(data) {
this.emit("data", data);
}

var stream = new MyStream();

console.log(stream instanceof events.EventEmitter); // true
console.log(MyStream.super_ === events.EventEmitter); // true
console.log(stream instanceof EventEmitter); // true
console.log(MyStream.super_ === EventEmitter); // true

stream.on("data", function(data) {
console.log('Received data: "' + data + '"');
Expand Down
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