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