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/internal/bootstrap/pre_execution.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/internal/bootstrap/pre_execution.js')
-rw-r--r-- | lib/internal/bootstrap/pre_execution.js | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/internal/bootstrap/pre_execution.js b/lib/internal/bootstrap/pre_execution.js index db50c3d0ee..b373801592 100644 --- a/lib/internal/bootstrap/pre_execution.js +++ b/lib/internal/bootstrap/pre_execution.js @@ -1,6 +1,9 @@ 'use strict'; -const { Object, SafeWeakMap } = primordials; +const { + ObjectDefineProperty, + SafeWeakMap, +} = primordials; const { getOptionValue } = require('internal/options'); const { Buffer } = require('buffer'); @@ -74,7 +77,7 @@ function patchProcessObject(expandArgv1) { patchProcessObjectNative(process); - Object.defineProperty(process, 'argv0', { + ObjectDefineProperty(process, 'argv0', { enumerable: true, configurable: false, value: process.argv[0] @@ -107,7 +110,7 @@ function patchProcessObject(expandArgv1) { function addReadOnlyProcessAlias(name, option, enumerable = true) { const value = getOptionValue(option); if (value) { - Object.defineProperty(process, name, { + ObjectDefineProperty(process, name, { writable: false, configurable: true, enumerable, @@ -153,7 +156,7 @@ function initializeReport() { } const { report } = require('internal/process/report'); const { emitExperimentalWarning } = require('internal/util'); - Object.defineProperty(process, 'report', { + ObjectDefineProperty(process, 'report', { enumerable: false, configurable: true, get() { @@ -273,7 +276,7 @@ function initializeDeprecations() { // process.features. const { noBrowserGlobals } = internalBinding('config'); if (noBrowserGlobals) { - Object.defineProperty(process, '_noBrowserGlobals', { + ObjectDefineProperty(process, '_noBrowserGlobals', { writable: false, enumerable: true, configurable: true, @@ -295,7 +298,7 @@ function initializeDeprecations() { // deprecation path for these in ES Modules. // See https://github.com/nodejs/node/pull/26334. let _process = process; - Object.defineProperty(global, 'process', { + ObjectDefineProperty(global, 'process', { get() { return _process; }, @@ -307,7 +310,7 @@ function initializeDeprecations() { }); let _Buffer = Buffer; - Object.defineProperty(global, 'Buffer', { + ObjectDefineProperty(global, 'Buffer', { get() { return _Buffer; }, |