diff options
author | Michaël Zasso <targos@protonmail.com> | 2019-11-22 18:04:46 +0100 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2019-11-25 10:28:15 +0100 |
commit | 0646eda4fc0affb98e13c30acb522e63b7fd6dde (patch) | |
tree | 078209f50b044e24ea2c72cbbe7dca6e34bb7e25 /lib/domain.js | |
parent | 35c6e0cc2b56a5380e6808ef5603ecc2b167e032 (diff) | |
download | android-node-v8-0646eda4fc0affb98e13c30acb522e63b7fd6dde.tar.gz android-node-v8-0646eda4fc0affb98e13c30acb522e63b7fd6dde.tar.bz2 android-node-v8-0646eda4fc0affb98e13c30acb522e63b7fd6dde.zip |
lib: flatten access to primordials
Store all primordials as properties of the primordials object.
Static functions are prefixed by the constructor's name and prototype
methods are prefixed by the constructor's name followed by "Prototype".
For example: primordials.Object.keys becomes primordials.ObjectKeys.
PR-URL: https://github.com/nodejs/node/pull/30610
Refs: https://github.com/nodejs/node/issues/29766
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
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; |