Skip to content

Instantly share code, notes, and snippets.

@jblebrun
Created April 11, 2017 16:29
Show Gist options
  • Save jblebrun/5b43760dc144532e444e1e7af03dcab1 to your computer and use it in GitHub Desktop.
Save jblebrun/5b43760dc144532e444e1e7af03dcab1 to your computer and use it in GitHub Desktop.
EventEmitter in node.js master, April 2017
function EventEmitter() {
EventEmitter.init.call(this);
}
/*...*/
EventEmitter.init = function() {
this.domain = null;
if (EventEmitter.usingDomains) {
// if there is an active domain, then attach to it.
domain = domain || require('domain');
if (domain.active && !(this instanceof domain.Domain)) {
this.domain = domain.active;
}
}
if (!this._events || this._events === Object.getPrototypeOf(this)._events) {
this._events = Object.create(null);
this._eventsCount = 0;
}
this._maxListeners = this._maxListeners || undefined;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment