doc: remove usage of events.EventEmitter
authorSakthipriyan Vairamani <thechargingvolcano@gmail.com>
Wed, 16 Sep 2015 22:42:27 +0000 (04:12 +0530)
committerRod Vagg <rod@vagg.org>
Tue, 22 Sep 2015 22:39:34 +0000 (08:39 +1000)
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>
doc/api/errors.markdown
doc/api/events.markdown
doc/api/modules.markdown
doc/api/util.markdown

index 0ef1b07..04d3d97 100644 (file)
@@ -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
index bd227a3..8a9301c 100644 (file)
@@ -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
index 4dc1086..57cd78b 100644 (file)
@@ -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();
 
index 0f2aa10..9914deb 100644 (file)
@@ -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 + '"');