diff --git a/lib/events.js b/lib/events.js index 729800864e..e2e39fd6e5 100644 --- a/lib/events.js +++ b/lib/events.js @@ -22,11 +22,9 @@ var domain; var util = require('util'); -exports.usingDomains = false; - function EventEmitter() { this.domain = null; - if (exports.usingDomains) { + if (EventEmitter.usingDomains) { // if there is an active domain, then attach to it. domain = domain || require('domain'); if (domain.active && !(this instanceof domain.Domain)) { @@ -36,7 +34,12 @@ function EventEmitter() { this._events = this._events || {}; this._maxListeners = this._maxListeners || undefined; } -exports.EventEmitter = EventEmitter; +module.exports = EventEmitter; + +// Backwards-compat with node 0.10.x +EventEmitter.EventEmitter = EventEmitter; + +EventEmitter.usingDomains = false; EventEmitter.prototype.domain = undefined; EventEmitter.prototype._events = undefined;