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>
This commit is contained in:
Michaël Zasso 2019-11-22 18:04:46 +01:00
parent 35c6e0cc2b
commit 0646eda4fc
No known key found for this signature in database
GPG key ID: 770F7A9A5AE15600
117 changed files with 1317 additions and 943 deletions

View file

@ -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