Skip to content

Commit

Permalink
doc: 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 <me@silverwind.io>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
  • Loading branch information
thefourtheye authored and rvagg committed Sep 22, 2015
1 parent 9760e04 commit 43e2b7f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
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

0 comments on commit 43e2b7f

Please sign in to comment.