diff --git a/doc/api/errors.markdown b/doc/api/errors.markdown index 0ef1b0730d0555..04d3d97a52b0f5 100644 --- a/doc/api/errors.markdown +++ b/doc/api/errors.markdown @@ -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 diff --git a/doc/api/events.markdown b/doc/api/events.markdown index bd227a34db5b35..8a9301cff6fbbd 100644 --- a/doc/api/events.markdown +++ b/doc/api/events.markdown @@ -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 diff --git a/doc/api/modules.markdown b/doc/api/modules.markdown index 4dc1086e6bcffa..57cd78b36b6738 100644 --- a/doc/api/modules.markdown +++ b/doc/api/modules.markdown @@ -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(); diff --git a/doc/api/util.markdown b/doc/api/util.markdown index 0f2aa107302c29..9914deb48050db 100644 --- a/doc/api/util.markdown +++ b/doc/api/util.markdown @@ -426,13 +426,13 @@ 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); @@ -440,8 +440,8 @@ through the `constructor.super_` property. 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 + '"'); diff --git a/lib/_http_agent.js b/lib/_http_agent.js index c18f39a38c6e2d..305baa2cbd2f03 100644 --- a/lib/_http_agent.js +++ b/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. diff --git a/lib/_http_client.js b/lib/_http_client.js index e490dce5d821d6..4610225d88f5f6 100644 --- a/lib/_http_client.js +++ b/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'); diff --git a/lib/_http_server.js b/lib/_http_server.js index 7acc1086387880..f2e2dcf001b03d 100644 --- a/lib/_http_server.js +++ b/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) } diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index c6bd0c16659d1e..64ff744b8db677 100644 --- a/lib/_stream_readable.js +++ b/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'); diff --git a/lib/_tls_legacy.js b/lib/_tls_legacy.js index e0c60dbdf6ea83..1d700c9218f538 100644 --- a/lib/_tls_legacy.js +++ b/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 */ diff --git a/lib/cluster.js b/lib/cluster.js index 84d7c766cb588b..602cc8d60b9200 100644 --- a/lib/cluster.js +++ b/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; diff --git a/lib/dgram.js b/lib/dgram.js index 5d207a5ef6475c..eaf84272d16284 100644 --- a/lib/dgram.js +++ b/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; diff --git a/lib/fs.js b/lib/fs.js index eeb3806cdc8861..76f53db9ba7ec4 100644 --- a/lib/fs.js +++ b/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; diff --git a/lib/http.js b/lib/http.js index cead865749bfd9..64788dd5c07f9f 100644 --- a/lib/http.js +++ b/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; diff --git a/lib/internal/child_process.js b/lib/internal/child_process.js index 328a67d1ef0962..d1596406cf9d53 100644 --- a/lib/internal/child_process.js +++ b/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'); diff --git a/lib/internal/socket_list.js b/lib/internal/socket_list.js index e9b388d420c29a..950d632a26360d 100644 --- a/lib/internal/socket_list.js +++ b/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 diff --git a/lib/net.js b/lib/net.js index 8245601e51733a..47422c30dbbea1 100644 --- a/lib/net.js +++ b/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; diff --git a/lib/readline.js b/lib/readline.js index 6164bcc85fb8ff..ca99374718098b 100644 --- a/lib/readline.js +++ b/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) { diff --git a/lib/stream.js b/lib/stream.js index 8d3535dc4d2f0e..047fbceb4bdb30 100644 --- a/lib/stream.js +++ b/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); diff --git a/src/node.js b/src/node.js index bd91fb888ae046..001a47657f816a 100644 --- a/src/node.js +++ b/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: {