From 43e2b7f836c17bb8d8fdc9223ca4c8d2a91b7a5b Mon Sep 17 00:00:00 2001 From: Sakthipriyan Vairamani Date: Thu, 17 Sep 2015 04:12:27 +0530 Subject: [PATCH] doc: remove usage of events.EventEmitter MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Reviewed-By: Michaël Zasso --- doc/api/errors.markdown | 4 ++-- doc/api/events.markdown | 2 +- doc/api/modules.markdown | 2 +- doc/api/util.markdown | 10 +++++----- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/doc/api/errors.markdown b/doc/api/errors.markdown index 0ef1b07..04d3d97 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 bd227a3..8a9301c 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 4dc1086..57cd78b 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 0f2aa10..9914deb 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 + '"'); -- 2.7.4