events: cache domain
module locally
It's faster than calling `require` every time we create an `EventEmitter`.
This commit is contained in:
parent
71a2a2caa6
commit
3db2e034c4
@ -20,11 +20,12 @@
|
|||||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
var isArray = Array.isArray;
|
var isArray = Array.isArray;
|
||||||
|
var domain;
|
||||||
|
|
||||||
function EventEmitter() {
|
function EventEmitter() {
|
||||||
if (exports.usingDomains) {
|
if (exports.usingDomains) {
|
||||||
// if there is an active domain, then attach to it.
|
// if there is an active domain, then attach to it.
|
||||||
var domain = require('domain');
|
domain = domain || require('domain');
|
||||||
if (domain.active && !(this instanceof domain.Domain)) {
|
if (domain.active && !(this instanceof domain.Domain)) {
|
||||||
this.domain = domain.active;
|
this.domain = domain.active;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user