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/perf_hooks.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/perf_hooks.js')
-rw-r--r-- | lib/perf_hooks.js | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/perf_hooks.js b/lib/perf_hooks.js index 18b0332fea..ac4fc405c5 100644 --- a/lib/perf_hooks.js +++ b/lib/perf_hooks.js @@ -1,6 +1,10 @@ 'use strict'; -const { Object } = primordials; +const { + ObjectDefineProperties, + ObjectDefineProperty, + ObjectKeys, +} = primordials; const { ELDHistogram: _ELDHistogram, @@ -215,7 +219,7 @@ const nodeTiming = new PerformanceNodeTiming(); // Maintains a list of entries as a linked list stored in insertion order. class PerformanceObserverEntryList { constructor() { - Object.defineProperties(this, { + ObjectDefineProperties(this, { [kEntries]: { writable: true, enumerable: false, @@ -280,7 +284,7 @@ class PerformanceObserver extends AsyncResource { throw new ERR_INVALID_CALLBACK(callback); } super('PerformanceObserver'); - Object.defineProperties(this, { + ObjectDefineProperties(this, { [kTypes]: { enumerable: false, writable: true, @@ -312,7 +316,7 @@ class PerformanceObserver extends AsyncResource { disconnect() { const observerCountsGC = observerCounts[NODE_PERFORMANCE_ENTRY_TYPE_GC]; const types = this[kTypes]; - const keys = Object.keys(types); + const keys = ObjectKeys(types); for (var n = 0; n < keys.length; n++) { const item = types[keys[n]]; if (item) { @@ -413,13 +417,13 @@ class Performance { if (fn[kTimerified]) return fn[kTimerified]; const ret = timerify(fn, fn.length); - Object.defineProperty(fn, kTimerified, { + ObjectDefineProperty(fn, kTimerified, { enumerable: false, configurable: true, writable: false, value: ret }); - Object.defineProperties(ret, { + ObjectDefineProperties(ret, { [kTimerified]: { enumerable: false, configurable: true, @@ -610,7 +614,7 @@ module.exports = { monitorEventLoopDelay }; -Object.defineProperty(module.exports, 'constants', { +ObjectDefineProperty(module.exports, 'constants', { configurable: false, enumerable: true, value: constants |