Browse Source

doc: remove usage of events.EventEmitter

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>
v5.x
Sakthipriyan Vairamani 9 years ago
parent
commit
7953c83b85
  1. 4
      doc/api/errors.markdown
  2. 2
      doc/api/events.markdown
  3. 2
      doc/api/modules.markdown
  4. 10
      doc/api/util.markdown

4
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: errors when no error handlers are attached. An example:
```javascript ```javascript
var events = require('events'); var EventEmitter = require('events');
var ee = new events.EventEmitter; var ee = new EventEmitter();
setImmediate(function() { setImmediate(function() {
// this will crash the process because no "error" event // this will crash the process because no "error" event

2
doc/api/events.markdown

@ -177,7 +177,7 @@ constructor function. For example:
'use strict'; 'use strict';
const util = require('util'); const util = require('util');
const EventEmitter = require('events').EventEmitter; const EventEmitter = require('events');
function MyEventEmitter() { function MyEventEmitter() {
// Initialize necessary properties from `EventEmitter` in this instance // Initialize necessary properties from `EventEmitter` in this instance

2
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` For example suppose we were making a module called `a.js`
var EventEmitter = require('events').EventEmitter; var EventEmitter = require('events');
module.exports = new EventEmitter(); module.exports = new EventEmitter();

10
doc/api/util.markdown

@ -426,13 +426,13 @@ As an additional convenience, `superConstructor` will be accessible
through the `constructor.super_` property. through the `constructor.super_` property.
var util = require("util"); var util = require("util");
var events = require("events"); var EventEmitter = require("events");
function MyStream() { function MyStream() {
events.EventEmitter.call(this); EventEmitter.call(this);
} }
util.inherits(MyStream, events.EventEmitter); util.inherits(MyStream, EventEmitter);
MyStream.prototype.write = function(data) { MyStream.prototype.write = function(data) {
this.emit("data", data); this.emit("data", data);
@ -440,8 +440,8 @@ through the `constructor.super_` property.
var stream = new MyStream(); var stream = new MyStream();
console.log(stream instanceof events.EventEmitter); // true console.log(stream instanceof EventEmitter); // true
console.log(MyStream.super_ === events.EventEmitter); // true console.log(MyStream.super_ === EventEmitter); // true
stream.on("data", function(data) { stream.on("data", function(data) {
console.log('Received data: "' + data + '"'); console.log('Received data: "' + data + '"');

Loading…
Cancel
Save