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
117 changed files with 1317 additions and 943 deletions

View File

@@ -1,6 +1,9 @@
'use strict';
const { Object } = primordials;
const {
ObjectDefineProperty,
ObjectSetPrototypeOf,
} = primordials;
const {
errnoException,
@@ -281,8 +284,8 @@ function ChildProcess() {
maybeClose(this);
};
}
Object.setPrototypeOf(ChildProcess.prototype, EventEmitter.prototype);
Object.setPrototypeOf(ChildProcess, EventEmitter);
ObjectSetPrototypeOf(ChildProcess.prototype, EventEmitter.prototype);
ObjectSetPrototypeOf(ChildProcess, EventEmitter);
function flushStdio(subprocess) {
@@ -528,7 +531,7 @@ let serialization;
function setupChannel(target, channel, serializationMode) {
target.channel = channel;
Object.defineProperty(target, '_channel', {
ObjectDefineProperty(target, '_channel', {
get: deprecate(() => {
return target.channel;
}, channelDeprecationMsg, 'DEP0129'),