diff options
Diffstat (limited to 'lib/domain.js')
-rw-r--r-- | lib/domain.js | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/lib/domain.js b/lib/domain.js index c3e38ba832..7c35a7c81a 100644 --- a/lib/domain.js +++ b/lib/domain.js @@ -26,7 +26,10 @@ // No new pull requests targeting this module will be accepted // unless they address existing, critical bugs. -const { Object, Reflect } = primordials; +const { + ObjectDefineProperty, + ReflectApply, +} = primordials; const EventEmitter = require('events'); const { @@ -43,7 +46,7 @@ const { WeakReference } = internalBinding('util'); // Overwrite process.domain with a getter/setter that will allow for more // effective optimizations const _domain = [null]; -Object.defineProperty(process, 'domain', { +ObjectDefineProperty(process, 'domain', { enumerable: true, get: function() { return _domain[0]; @@ -59,7 +62,7 @@ const asyncHook = createHook({ if (process.domain !== null && process.domain !== undefined) { // If this operation is created while in a domain, let's mark it pairing.set(asyncId, process.domain[kWeak]); - Object.defineProperty(resource, 'domain', { + ObjectDefineProperty(resource, 'domain', { configurable: true, enumerable: false, value: process.domain, @@ -127,7 +130,7 @@ function topLevelDomainCallback(cb, ...args) { if (domain) domain.enter(); - const ret = Reflect.apply(cb, this, args); + const ret = ReflectApply(cb, this, args); if (domain) domain.exit(); @@ -207,7 +210,7 @@ Domain.prototype._errorHandler = function(er) { let caught = false; if ((typeof er === 'object' && er !== null) || typeof er === 'function') { - Object.defineProperty(er, 'domain', { + ObjectDefineProperty(er, 'domain', { configurable: true, enumerable: false, value: this, @@ -332,7 +335,7 @@ Domain.prototype.add = function(ee) { } } - Object.defineProperty(ee, 'domain', { + ObjectDefineProperty(ee, 'domain', { configurable: true, enumerable: false, value: this, @@ -376,7 +379,7 @@ function intercepted(_this, self, cb, fnargs) { const er = fnargs[0]; er.domainBound = cb; er.domainThrown = false; - Object.defineProperty(er, 'domain', { + ObjectDefineProperty(er, 'domain', { configurable: true, enumerable: false, value: self, @@ -435,7 +438,7 @@ Domain.prototype.bind = function(cb) { return bound(this, self, cb, arguments); } - Object.defineProperty(runBound, 'domain', { + ObjectDefineProperty(runBound, 'domain', { configurable: true, enumerable: false, value: this, @@ -450,7 +453,7 @@ EventEmitter.usingDomains = true; const eventInit = EventEmitter.init; EventEmitter.init = function() { - Object.defineProperty(this, 'domain', { + ObjectDefineProperty(this, 'domain', { configurable: true, enumerable: false, value: null, @@ -475,7 +478,7 @@ EventEmitter.prototype.emit = function(...args) { // handler, there's no active domain or this is process if (shouldEmitError || domain === null || domain === undefined || this === process) { - return Reflect.apply(eventEmit, this, args); + return ReflectApply(eventEmit, this, args); } if (type === 'error') { @@ -484,7 +487,7 @@ EventEmitter.prototype.emit = function(...args) { if (typeof er === 'object') { er.domainEmitter = this; - Object.defineProperty(er, 'domain', { + ObjectDefineProperty(er, 'domain', { configurable: true, enumerable: false, value: domain, @@ -537,7 +540,7 @@ EventEmitter.prototype.emit = function(...args) { } domain.enter(); - const ret = Reflect.apply(eventEmit, this, args); + const ret = ReflectApply(eventEmit, this, args); domain.exit(); return ret; |