From 0646eda4fc0affb98e13c30acb522e63b7fd6dde Mon Sep 17 00:00:00 2001 From: Michaƫl Zasso Date: Fri, 22 Nov 2019 18:04:46 +0100 Subject: 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 Reviewed-By: Matteo Collina Reviewed-By: Colin Ihrig Reviewed-By: Trivikram Kamat --- lib/perf_hooks.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'lib/perf_hooks.js') 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 -- cgit v1.2.3