summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/.eslintrc.yaml2
-rw-r--r--lib/_http_agent.js2
-rw-r--r--lib/_http_client.js2
-rw-r--r--lib/_http_incoming.js2
-rw-r--r--lib/_http_outgoing.js2
-rw-r--r--lib/_http_server.js2
-rw-r--r--lib/_stream_duplex.js2
-rw-r--r--lib/_stream_passthrough.js2
-rw-r--r--lib/_stream_readable.js2
-rw-r--r--lib/_stream_transform.js2
-rw-r--r--lib/_stream_writable.js2
-rw-r--r--lib/_tls_common.js2
-rw-r--r--lib/_tls_wrap.js2
-rw-r--r--lib/assert.js2
-rw-r--r--lib/buffer.js2
-rw-r--r--lib/child_process.js5
-rw-r--r--lib/constants.js2
-rw-r--r--lib/crypto.js2
-rw-r--r--lib/dgram.js2
-rw-r--r--lib/dns.js2
-rw-r--r--lib/domain.js2
-rw-r--r--lib/events.js2
-rw-r--r--lib/fs.js2
-rw-r--r--lib/http.js2
-rw-r--r--lib/https.js2
-rw-r--r--lib/internal/assert/assertion_error.js2
-rw-r--r--lib/internal/async_hooks.js2
-rw-r--r--lib/internal/bootstrap/pre_execution.js2
-rw-r--r--lib/internal/child_process.js2
-rw-r--r--lib/internal/cluster/child.js3
-rw-r--r--lib/internal/cluster/master.js8
-rw-r--r--lib/internal/cluster/worker.js3
-rw-r--r--lib/internal/console/constructor.js17
-rw-r--r--lib/internal/console/global.js2
-rw-r--r--lib/internal/crypto/cipher.js2
-rw-r--r--lib/internal/crypto/diffiehellman.js2
-rw-r--r--lib/internal/crypto/hash.js2
-rw-r--r--lib/internal/crypto/keygen.js2
-rw-r--r--lib/internal/crypto/keys.js2
-rw-r--r--lib/internal/crypto/sig.js2
-rw-r--r--lib/internal/dns/promises.js3
-rw-r--r--lib/internal/encoding.js2
-rw-r--r--lib/internal/errors.js9
-rw-r--r--lib/internal/fs/streams.js2
-rw-r--r--lib/internal/fs/sync_write_stream.js2
-rw-r--r--lib/internal/fs/watchers.js2
-rw-r--r--lib/internal/http2/compat.js4
-rw-r--r--lib/internal/http2/core.js2
-rw-r--r--lib/internal/http2/util.js2
-rw-r--r--lib/internal/main/worker_thread.js2
-rw-r--r--lib/internal/modules/cjs/helpers.js2
-rw-r--r--lib/internal/modules/cjs/loader.js2
-rw-r--r--lib/internal/modules/esm/module_job.js4
-rw-r--r--lib/internal/per_context/domexception.js4
-rw-r--r--lib/internal/process/per_thread.js1
-rw-r--r--lib/internal/process/policy.js2
-rw-r--r--lib/internal/repl.js2
-rw-r--r--lib/internal/repl/await.js2
-rw-r--r--lib/internal/streams/async_iterator.js2
-rw-r--r--lib/internal/streams/lazy_transform.js2
-rw-r--r--lib/internal/streams/legacy.js2
-rw-r--r--lib/internal/timers.js2
-rw-r--r--lib/internal/tls.js2
-rw-r--r--lib/internal/trace_events_async_hooks.js3
-rw-r--r--lib/internal/url.js2
-rw-r--r--lib/internal/util.js7
-rw-r--r--lib/internal/util/inspector.js2
-rw-r--r--lib/internal/util/types.js2
-rw-r--r--lib/internal/vm/source_text_module.js3
-rw-r--r--lib/internal/worker.js2
-rw-r--r--lib/internal/worker/io.js2
-rw-r--r--lib/net.js2
-rw-r--r--lib/os.js2
-rw-r--r--lib/perf_hooks.js2
-rw-r--r--lib/querystring.js2
-rw-r--r--lib/readline.js2
-rw-r--r--lib/repl.js11
-rw-r--r--lib/stream.js2
-rw-r--r--lib/string_decoder.js2
-rw-r--r--lib/tty.js2
-rw-r--r--lib/url.js3
-rw-r--r--lib/util.js2
-rw-r--r--lib/v8.js7
-rw-r--r--lib/zlib.js2
-rw-r--r--src/node.cc2
85 files changed, 167 insertions, 64 deletions
diff --git a/lib/.eslintrc.yaml b/lib/.eslintrc.yaml
index 12375c06ed..ef3236b362 100644
--- a/lib/.eslintrc.yaml
+++ b/lib/.eslintrc.yaml
@@ -10,6 +10,8 @@ rules:
message: "Use `const { JSON } = primordials;` instead of the global."
- name: Math
message: "Use `const { Math } = primordials;` instead of the global."
+ - name: Object
+ message: "Use `const { Object } = primordials;` instead of the global."
- name: Reflect
message: "Use `const { Reflect } = primordials;` instead of the global."
no-restricted-syntax:
diff --git a/lib/_http_agent.js b/lib/_http_agent.js
index 41fe003c08..32dbf27abc 100644
--- a/lib/_http_agent.js
+++ b/lib/_http_agent.js
@@ -21,6 +21,8 @@
'use strict';
+const { Object } = primordials;
+
const net = require('net');
const EventEmitter = require('events');
const debug = require('internal/util/debuglog').debuglog('http');
diff --git a/lib/_http_client.js b/lib/_http_client.js
index 70e8e55ead..e23c4909dd 100644
--- a/lib/_http_client.js
+++ b/lib/_http_client.js
@@ -21,6 +21,8 @@
'use strict';
+const { Object } = primordials;
+
const net = require('net');
const url = require('url');
const assert = require('internal/assert');
diff --git a/lib/_http_incoming.js b/lib/_http_incoming.js
index 5d098a1781..3ec23616b1 100644
--- a/lib/_http_incoming.js
+++ b/lib/_http_incoming.js
@@ -21,6 +21,8 @@
'use strict';
+const { Object } = primordials;
+
const Stream = require('stream');
function readStart(socket) {
diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js
index 2c2346d211..388204fbf2 100644
--- a/lib/_http_outgoing.js
+++ b/lib/_http_outgoing.js
@@ -21,7 +21,7 @@
'use strict';
-const { ObjectPrototype } = primordials;
+const { Object, ObjectPrototype } = primordials;
const assert = require('internal/assert');
const Stream = require('stream');
diff --git a/lib/_http_server.js b/lib/_http_server.js
index bc2c80599d..ff29b9d2b6 100644
--- a/lib/_http_server.js
+++ b/lib/_http_server.js
@@ -21,6 +21,8 @@
'use strict';
+const { Object } = primordials;
+
const net = require('net');
const assert = require('internal/assert');
const {
diff --git a/lib/_stream_duplex.js b/lib/_stream_duplex.js
index 11651e2ace..49520c4074 100644
--- a/lib/_stream_duplex.js
+++ b/lib/_stream_duplex.js
@@ -26,6 +26,8 @@
'use strict';
+const { Object } = primordials;
+
module.exports = Duplex;
const Readable = require('_stream_readable');
diff --git a/lib/_stream_passthrough.js b/lib/_stream_passthrough.js
index 404617f58e..205a14b65f 100644
--- a/lib/_stream_passthrough.js
+++ b/lib/_stream_passthrough.js
@@ -25,6 +25,8 @@
'use strict';
+const { Object } = primordials;
+
module.exports = PassThrough;
const Transform = require('_stream_transform');
diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js
index ec4c9d3631..1b6f2175ce 100644
--- a/lib/_stream_readable.js
+++ b/lib/_stream_readable.js
@@ -21,6 +21,8 @@
'use strict';
+const { Object } = primordials;
+
module.exports = Readable;
Readable.ReadableState = ReadableState;
diff --git a/lib/_stream_transform.js b/lib/_stream_transform.js
index cec617dfb6..ab6ada8dec 100644
--- a/lib/_stream_transform.js
+++ b/lib/_stream_transform.js
@@ -63,6 +63,8 @@
'use strict';
+const { Object } = primordials;
+
module.exports = Transform;
const {
ERR_METHOD_NOT_IMPLEMENTED,
diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js
index 7f9eeb6793..9d06adc775 100644
--- a/lib/_stream_writable.js
+++ b/lib/_stream_writable.js
@@ -25,6 +25,8 @@
'use strict';
+const { Object } = primordials;
+
module.exports = Writable;
Writable.WritableState = WritableState;
diff --git a/lib/_tls_common.js b/lib/_tls_common.js
index a0ef6934e3..2a4ad9b24e 100644
--- a/lib/_tls_common.js
+++ b/lib/_tls_common.js
@@ -21,6 +21,8 @@
'use strict';
+const { Object } = primordials;
+
const { parseCertString } = require('internal/tls');
const { isArrayBufferView } = require('internal/util/types');
const tls = require('tls');
diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js
index f8a9e938c0..51cd5ae32b 100644
--- a/lib/_tls_wrap.js
+++ b/lib/_tls_wrap.js
@@ -21,6 +21,8 @@
'use strict';
+const { Object } = primordials;
+
const {
assertCrypto,
deprecate
diff --git a/lib/assert.js b/lib/assert.js
index d76ea86db4..376f4b7320 100644
--- a/lib/assert.js
+++ b/lib/assert.js
@@ -20,6 +20,8 @@
'use strict';
+const { Object } = primordials;
+
const { Buffer } = require('buffer');
const { codes: {
ERR_AMBIGUOUS_ARGUMENT,
diff --git a/lib/buffer.js b/lib/buffer.js
index 1a9d81ab3a..005532bbee 100644
--- a/lib/buffer.js
+++ b/lib/buffer.js
@@ -21,7 +21,7 @@
'use strict';
-const { Math } = primordials;
+const { Math, Object } = primordials;
const {
byteLengthUtf8,
diff --git a/lib/child_process.js b/lib/child_process.js
index dd9d0fd0d8..d16a259122 100644
--- a/lib/child_process.js
+++ b/lib/child_process.js
@@ -21,6 +21,8 @@
'use strict';
+const { Object, ObjectPrototype } = primordials;
+
const {
promisify,
convertToValidSignal,
@@ -515,8 +517,7 @@ function normalizeSpawnArguments(file, args, options) {
// process.env.NODE_V8_COVERAGE always propagates, making it possible to
// collect coverage for programs that spawn with white-listed environment.
if (process.env.NODE_V8_COVERAGE &&
- !Object.prototype.hasOwnProperty.call(options.env || {},
- 'NODE_V8_COVERAGE')) {
+ !ObjectPrototype.hasOwnProperty(options.env || {}, 'NODE_V8_COVERAGE')) {
env.NODE_V8_COVERAGE = process.env.NODE_V8_COVERAGE;
}
diff --git a/lib/constants.js b/lib/constants.js
index 44c7388580..77341c0646 100644
--- a/lib/constants.js
+++ b/lib/constants.js
@@ -21,6 +21,8 @@
'use strict';
+const { Object } = primordials;
+
// This module is deprecated in documentation only. Users should be directed
// towards using the specific constants exposed by the individual modules on
// which they are most relevant.
diff --git a/lib/crypto.js b/lib/crypto.js
index 44d4800624..6bfa8319c1 100644
--- a/lib/crypto.js
+++ b/lib/crypto.js
@@ -24,6 +24,8 @@
'use strict';
+const { Object } = primordials;
+
const {
assertCrypto,
deprecate
diff --git a/lib/dgram.js b/lib/dgram.js
index 54cbc0faed..64192c4b52 100644
--- a/lib/dgram.js
+++ b/lib/dgram.js
@@ -21,6 +21,8 @@
'use strict';
+const { Object } = primordials;
+
const errors = require('internal/errors');
const {
kStateSymbol,
diff --git a/lib/dns.js b/lib/dns.js
index f9c724e7b6..b212983c44 100644
--- a/lib/dns.js
+++ b/lib/dns.js
@@ -21,6 +21,8 @@
'use strict';
+const { Object } = primordials;
+
const cares = internalBinding('cares_wrap');
const { toASCII } = require('internal/idna');
const { isIP, isIPv4, isLegalPort } = require('internal/net');
diff --git a/lib/domain.js b/lib/domain.js
index 608d5daceb..eab0b352bc 100644
--- a/lib/domain.js
+++ b/lib/domain.js
@@ -26,7 +26,7 @@
// No new pull requests targeting this module will be accepted
// unless they address existing, critical bugs.
-const { Reflect } = primordials;
+const { Object, Reflect } = primordials;
const util = require('util');
const EventEmitter = require('events');
diff --git a/lib/events.js b/lib/events.js
index 847074206e..3deb155479 100644
--- a/lib/events.js
+++ b/lib/events.js
@@ -21,7 +21,7 @@
'use strict';
-const { Math, Reflect } = primordials;
+const { Math, Object, Reflect } = primordials;
var spliceOne;
diff --git a/lib/fs.js b/lib/fs.js
index e7f5f69bdf..38c13613cb 100644
--- a/lib/fs.js
+++ b/lib/fs.js
@@ -24,7 +24,7 @@
'use strict';
-const { Math, Reflect } = primordials;
+const { Math, Object, Reflect } = primordials;
const { fs: constants } = internalBinding('constants');
const {
diff --git a/lib/http.js b/lib/http.js
index 5f0b383a48..8582557446 100644
--- a/lib/http.js
+++ b/lib/http.js
@@ -21,6 +21,8 @@
'use strict';
+const { Object } = primordials;
+
const httpAgent = require('_http_agent');
const { ClientRequest } = require('_http_client');
const { methods } = require('_http_common');
diff --git a/lib/https.js b/lib/https.js
index 715f86878a..4e64901731 100644
--- a/lib/https.js
+++ b/lib/https.js
@@ -21,6 +21,8 @@
'use strict';
+const { Object } = primordials;
+
require('internal/util').assertCrypto();
const tls = require('tls');
diff --git a/lib/internal/assert/assertion_error.js b/lib/internal/assert/assertion_error.js
index 5cefbf568f..7ab74e6777 100644
--- a/lib/internal/assert/assertion_error.js
+++ b/lib/internal/assert/assertion_error.js
@@ -1,6 +1,6 @@
'use strict';
-const { Math } = primordials;
+const { Math, Object } = primordials;
const { inspect } = require('internal/util/inspect');
const { codes: {
diff --git a/lib/internal/async_hooks.js b/lib/internal/async_hooks.js
index 9d30ad133d..cba8d15a6c 100644
--- a/lib/internal/async_hooks.js
+++ b/lib/internal/async_hooks.js
@@ -1,6 +1,6 @@
'use strict';
-const { FunctionPrototype, Reflect } = primordials;
+const { FunctionPrototype, Object, Reflect } = primordials;
const {
ERR_ASYNC_TYPE,
diff --git a/lib/internal/bootstrap/pre_execution.js b/lib/internal/bootstrap/pre_execution.js
index c1c58a81ff..e2b1103f8c 100644
--- a/lib/internal/bootstrap/pre_execution.js
+++ b/lib/internal/bootstrap/pre_execution.js
@@ -1,5 +1,7 @@
'use strict';
+const { Object } = primordials;
+
const { getOptionValue } = require('internal/options');
const { Buffer } = require('buffer');
diff --git a/lib/internal/child_process.js b/lib/internal/child_process.js
index 86736b1bd8..8e6a303a2e 100644
--- a/lib/internal/child_process.js
+++ b/lib/internal/child_process.js
@@ -1,6 +1,6 @@
'use strict';
-const { JSON } = primordials;
+const { JSON, Object } = primordials;
const {
errnoException,
diff --git a/lib/internal/cluster/child.js b/lib/internal/cluster/child.js
index d2f38a6b76..e7bddc1d0b 100644
--- a/lib/internal/cluster/child.js
+++ b/lib/internal/cluster/child.js
@@ -1,4 +1,7 @@
'use strict';
+
+const { Object } = primordials;
+
const assert = require('internal/assert');
const path = require('path');
const EventEmitter = require('events');
diff --git a/lib/internal/cluster/master.js b/lib/internal/cluster/master.js
index 3869ebbd8a..a881021c5e 100644
--- a/lib/internal/cluster/master.js
+++ b/lib/internal/cluster/master.js
@@ -1,4 +1,7 @@
'use strict';
+
+const { Object } = primordials;
+
const assert = require('internal/assert');
const { fork } = require('child_process');
const path = require('path');
@@ -8,7 +11,6 @@ const SharedHandle = require('internal/cluster/shared_handle');
const Worker = require('internal/cluster/worker');
const { internal, sendHelper } = require('internal/cluster/utils');
const { ERR_SOCKET_BAD_PORT } = require('internal/errors').codes;
-const keys = Object.keys;
const cluster = new EventEmitter();
const intercom = new EventEmitter();
const SCHED_NONE = 1;
@@ -141,7 +143,7 @@ function removeWorker(worker) {
assert(worker);
delete cluster.workers[worker.id];
- if (keys(cluster.workers).length === 0) {
+ if (Object.keys(cluster.workers).length === 0) {
assert(handles.size === 0, 'Resource leak detected.');
intercom.emit('disconnect');
}
@@ -219,7 +221,7 @@ function emitForkNT(worker) {
}
cluster.disconnect = function(cb) {
- const workers = keys(cluster.workers);
+ const workers = Object.keys(cluster.workers);
if (workers.length === 0) {
process.nextTick(() => intercom.emit('disconnect'));
diff --git a/lib/internal/cluster/worker.js b/lib/internal/cluster/worker.js
index 8033f82f2e..9d9c5dce83 100644
--- a/lib/internal/cluster/worker.js
+++ b/lib/internal/cluster/worker.js
@@ -1,4 +1,7 @@
'use strict';
+
+const { Object } = primordials;
+
const EventEmitter = require('events');
module.exports = Worker;
diff --git a/lib/internal/console/constructor.js b/lib/internal/console/constructor.js
index 46fd1e9c62..d3db1ec1ae 100644
--- a/lib/internal/console/constructor.js
+++ b/lib/internal/console/constructor.js
@@ -3,7 +3,7 @@
// The Console constructor is not actually used to construct the global
// console. It's exported for backwards compatibility.
-const { ObjectPrototype, Reflect } = primordials;
+const { Object, ObjectPrototype, Reflect } = primordials;
const { trace } = internalBinding('trace_events');
const {
@@ -33,11 +33,6 @@ const kTraceEnd = 'e'.charCodeAt(0);
const kTraceInstant = 'n'.charCodeAt(0);
const {
- keys: ObjectKeys,
- values: ObjectValues,
-} = Object;
-
-const {
isArray: ArrayIsArray,
from: ArrayFrom,
} = Array;
@@ -414,7 +409,7 @@ const consoleMethods = {
const depth = v !== null &&
typeof v === 'object' &&
!isArray(v) &&
- ObjectKeys(v).length > 2 ? -1 : 0;
+ Object.keys(v).length > 2 ? -1 : 0;
const opt = {
depth,
maxArrayLength: 3,
@@ -478,7 +473,7 @@ const consoleMethods = {
const map = {};
let hasPrimitives = false;
const valuesKeyArray = [];
- const indexKeyArray = ObjectKeys(tabularData);
+ const indexKeyArray = Object.keys(tabularData);
for (; i < indexKeyArray.length; i++) {
const item = tabularData[indexKeyArray[i]];
@@ -488,7 +483,7 @@ const consoleMethods = {
hasPrimitives = true;
valuesKeyArray[i] = _inspect(item);
} else {
- const keys = properties || ObjectKeys(item);
+ const keys = properties || Object.keys(item);
for (const key of keys) {
if (map[key] === undefined)
map[key] = [];
@@ -501,8 +496,8 @@ const consoleMethods = {
}
}
- const keys = ObjectKeys(map);
- const values = ObjectValues(map);
+ const keys = Object.keys(map);
+ const values = Object.values(map);
if (hasPrimitives) {
keys.push(valuesKey);
values.push(valuesKeyArray);
diff --git a/lib/internal/console/global.js b/lib/internal/console/global.js
index aac67fde15..bad7478f1e 100644
--- a/lib/internal/console/global.js
+++ b/lib/internal/console/global.js
@@ -12,7 +12,7 @@
// Therefore, the console.Console.prototype is not
// in the global console prototype chain anymore.
-const { Reflect } = primordials;
+const { Object, Reflect } = primordials;
const {
Console,
diff --git a/lib/internal/crypto/cipher.js b/lib/internal/crypto/cipher.js
index 28bd1e57a6..e2fe291526 100644
--- a/lib/internal/crypto/cipher.js
+++ b/lib/internal/crypto/cipher.js
@@ -1,5 +1,7 @@
'use strict';
+const { Object } = primordials;
+
const {
RSA_PKCS1_OAEP_PADDING,
RSA_PKCS1_PADDING
diff --git a/lib/internal/crypto/diffiehellman.js b/lib/internal/crypto/diffiehellman.js
index 7ec2ce6e41..7e0fde38bc 100644
--- a/lib/internal/crypto/diffiehellman.js
+++ b/lib/internal/crypto/diffiehellman.js
@@ -1,5 +1,7 @@
'use strict';
+const { Object } = primordials;
+
const { Buffer } = require('buffer');
const {
ERR_CRYPTO_ECDH_INVALID_FORMAT,
diff --git a/lib/internal/crypto/hash.js b/lib/internal/crypto/hash.js
index 89ab29d845..a581648021 100644
--- a/lib/internal/crypto/hash.js
+++ b/lib/internal/crypto/hash.js
@@ -1,5 +1,7 @@
'use strict';
+const { Object } = primordials;
+
const {
Hash: _Hash,
Hmac: _Hmac
diff --git a/lib/internal/crypto/keygen.js b/lib/internal/crypto/keygen.js
index 10ab49760b..f646f436f7 100644
--- a/lib/internal/crypto/keygen.js
+++ b/lib/internal/crypto/keygen.js
@@ -1,5 +1,7 @@
'use strict';
+const { Object } = primordials;
+
const { AsyncWrap, Providers } = internalBinding('async_wrap');
const {
generateKeyPairRSA,
diff --git a/lib/internal/crypto/keys.js b/lib/internal/crypto/keys.js
index 93d350e4e7..321506eaf4 100644
--- a/lib/internal/crypto/keys.js
+++ b/lib/internal/crypto/keys.js
@@ -1,5 +1,7 @@
'use strict';
+const { Object } = primordials;
+
const {
KeyObject: KeyObjectHandle,
kKeyTypeSecret,
diff --git a/lib/internal/crypto/sig.js b/lib/internal/crypto/sig.js
index eb75907217..b6a3376e73 100644
--- a/lib/internal/crypto/sig.js
+++ b/lib/internal/crypto/sig.js
@@ -1,5 +1,7 @@
'use strict';
+const { Object } = primordials;
+
const {
ERR_CRYPTO_SIGN_KEY_REQUIRED,
ERR_INVALID_ARG_TYPE,
diff --git a/lib/internal/dns/promises.js b/lib/internal/dns/promises.js
index 25696bf222..cd4607f485 100644
--- a/lib/internal/dns/promises.js
+++ b/lib/internal/dns/promises.js
@@ -1,4 +1,7 @@
'use strict';
+
+const { Object } = primordials;
+
const {
bindDefaultResolver,
Resolver: CallbackResolver,
diff --git a/lib/internal/encoding.js b/lib/internal/encoding.js
index b45a074f38..2de2cc565c 100644
--- a/lib/internal/encoding.js
+++ b/lib/internal/encoding.js
@@ -3,6 +3,8 @@
// An implementation of the WHATWG Encoding Standard
// https://encoding.spec.whatwg.org
+const { Object } = primordials;
+
const {
ERR_ENCODING_INVALID_ENCODED_DATA,
ERR_ENCODING_NOT_SUPPORTED,
diff --git a/lib/internal/errors.js b/lib/internal/errors.js
index d2bf1999c0..6334626d3c 100644
--- a/lib/internal/errors.js
+++ b/lib/internal/errors.js
@@ -10,13 +10,14 @@
// value statically and permanently identifies the error. While the error
// message may change, the code should not.
+const { Object } = primordials;
+
const kCode = Symbol('code');
const kInfo = Symbol('info');
const messages = new Map();
const codes = {};
const { kMaxLength } = internalBinding('buffer');
-const { defineProperty } = Object;
let excludedStackFn;
@@ -100,7 +101,7 @@ class SystemError extends Error {
}
set code(value) {
- defineProperty(this, 'code', {
+ Object.defineProperty(this, 'code', {
configurable: true,
enumerable: true,
value,
@@ -188,7 +189,7 @@ function makeNodeErrorWithCode(Base, key) {
}
set code(value) {
- defineProperty(this, 'code', {
+ Object.defineProperty(this, 'code', {
configurable: true,
enumerable: true,
value,
@@ -234,7 +235,7 @@ function addCodeToName(err, name, code) {
err.stack;
// Reset the name to the actual name.
if (name === 'SystemError') {
- defineProperty(err, 'name', {
+ Object.defineProperty(err, 'name', {
value: name,
enumerable: false,
writable: true,
diff --git a/lib/internal/fs/streams.js b/lib/internal/fs/streams.js
index 3b797edc58..97a8856797 100644
--- a/lib/internal/fs/streams.js
+++ b/lib/internal/fs/streams.js
@@ -1,6 +1,6 @@
'use strict';
-const { Math } = primordials;
+const { Math, Object } = primordials;
const {
FSReqCallback,
diff --git a/lib/internal/fs/sync_write_stream.js b/lib/internal/fs/sync_write_stream.js
index 0af289d7f4..522bfc829d 100644
--- a/lib/internal/fs/sync_write_stream.js
+++ b/lib/internal/fs/sync_write_stream.js
@@ -1,5 +1,7 @@
'use strict';
+const { Object } = primordials;
+
const { Writable } = require('stream');
const { closeSync, writeSync } = require('fs');
diff --git a/lib/internal/fs/watchers.js b/lib/internal/fs/watchers.js
index 2de58b7a1d..d29ed90258 100644
--- a/lib/internal/fs/watchers.js
+++ b/lib/internal/fs/watchers.js
@@ -1,5 +1,7 @@
'use strict';
+const { Object } = primordials;
+
const errors = require('internal/errors');
const {
kFsStatsFieldsNumber,
diff --git a/lib/internal/http2/compat.js b/lib/internal/http2/compat.js
index ba52c9adea..37f8242b00 100644
--- a/lib/internal/http2/compat.js
+++ b/lib/internal/http2/compat.js
@@ -1,6 +1,6 @@
'use strict';
-const { Reflect } = primordials;
+const { Object, ObjectPrototype, Reflect } = primordials;
const assert = require('internal/assert');
const Stream = require('stream');
@@ -539,7 +539,7 @@ class Http2ServerResponse extends Stream {
hasHeader(name) {
validateString(name, 'name');
name = name.trim().toLowerCase();
- return Object.prototype.hasOwnProperty.call(this[kHeaders], name);
+ return ObjectPrototype.hasOwnProperty(this[kHeaders], name);
}
removeHeader(name) {
diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js
index 2e5db4006f..ca6e23e061 100644
--- a/lib/internal/http2/core.js
+++ b/lib/internal/http2/core.js
@@ -2,7 +2,7 @@
/* eslint-disable no-use-before-define */
-const { Math, Reflect } = primordials;
+const { Math, Object, Reflect } = primordials;
const {
assertCrypto,
diff --git a/lib/internal/http2/util.js b/lib/internal/http2/util.js
index d22310f19d..9cc2a30897 100644
--- a/lib/internal/http2/util.js
+++ b/lib/internal/http2/util.js
@@ -1,6 +1,6 @@
'use strict';
-const { Math } = primordials;
+const { Math, Object } = primordials;
const binding = internalBinding('http2');
const {
diff --git a/lib/internal/main/worker_thread.js b/lib/internal/main/worker_thread.js
index 71babafd0e..0e463dc935 100644
--- a/lib/internal/main/worker_thread.js
+++ b/lib/internal/main/worker_thread.js
@@ -3,6 +3,8 @@
// In worker threads, execute the script sent through the
// message port.
+const { Object } = primordials;
+
const {
patchProcessObject,
setupCoverageHooks,
diff --git a/lib/internal/modules/cjs/helpers.js b/lib/internal/modules/cjs/helpers.js
index fd24a6fb3c..4b35302944 100644
--- a/lib/internal/modules/cjs/helpers.js
+++ b/lib/internal/modules/cjs/helpers.js
@@ -1,5 +1,7 @@
'use strict';
+const { Object } = primordials;
+
const { validateString } = require('internal/validators');
const path = require('path');
const { pathToFileURL } = require('internal/url');
diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js
index 14afb4e1db..5d0e777774 100644
--- a/lib/internal/modules/cjs/loader.js
+++ b/lib/internal/modules/cjs/loader.js
@@ -21,7 +21,7 @@
'use strict';
-const { JSON, Reflect } = primordials;
+const { JSON, Object, Reflect } = primordials;
const { NativeModule } = require('internal/bootstrap/loaders');
const { pathToFileURL } = require('internal/url');
diff --git a/lib/internal/modules/esm/module_job.js b/lib/internal/modules/esm/module_job.js
index 5666032df1..5ae3fabae7 100644
--- a/lib/internal/modules/esm/module_job.js
+++ b/lib/internal/modules/esm/module_job.js
@@ -1,11 +1,13 @@
'use strict';
-const { ModuleWrap } = internalBinding('module_wrap');
const {
+ Object,
SafeSet,
SafePromise
} = primordials;
+const { ModuleWrap } = internalBinding('module_wrap');
+
const { decorateErrorStack } = require('internal/util');
const assert = require('internal/assert');
const resolvedPromise = SafePromise.resolve();
diff --git a/lib/internal/per_context/domexception.js b/lib/internal/per_context/domexception.js
index 795acf76c0..729fe3757a 100644
--- a/lib/internal/per_context/domexception.js
+++ b/lib/internal/per_context/domexception.js
@@ -1,5 +1,9 @@
'use strict';
+// `per_context` scripts are executed before creating the primordials so we
+// cannot use them here.
+/* eslint-disable no-restricted-globals */
+
class ERR_INVALID_THIS extends TypeError {
constructor(type) {
super('Value of "this" must be of ' + type);
diff --git a/lib/internal/process/per_thread.js b/lib/internal/process/per_thread.js
index ef9012535f..35e861df2b 100644
--- a/lib/internal/process/per_thread.js
+++ b/lib/internal/process/per_thread.js
@@ -5,6 +5,7 @@
// thread and the worker threads.
const {
+ Object,
RegExpPrototype,
SetPrototype,
StringPrototype
diff --git a/lib/internal/process/policy.js b/lib/internal/process/policy.js
index 98c535f870..215e1420af 100644
--- a/lib/internal/process/policy.js
+++ b/lib/internal/process/policy.js
@@ -1,6 +1,6 @@
'use strict';
-const { JSON, Reflect } = primordials;
+const { JSON, Object, Reflect } = primordials;
const {
ERR_MANIFEST_TDZ,
diff --git a/lib/internal/repl.js b/lib/internal/repl.js
index 7ef14d33b3..cb368ea612 100644
--- a/lib/internal/repl.js
+++ b/lib/internal/repl.js
@@ -1,5 +1,7 @@
'use strict';
+const { Object } = primordials;
+
const REPL = require('repl');
const { kStandaloneREPL } = require('internal/repl/utils');
diff --git a/lib/internal/repl/await.js b/lib/internal/repl/await.js
index bcc94ef186..ac0445311b 100644
--- a/lib/internal/repl/await.js
+++ b/lib/internal/repl/await.js
@@ -1,5 +1,7 @@
'use strict';
+const { Object } = primordials;
+
const acorn = require('internal/deps/acorn/acorn/dist/acorn');
const walk = require('internal/deps/acorn/acorn-walk/dist/walk');
diff --git a/lib/internal/streams/async_iterator.js b/lib/internal/streams/async_iterator.js
index 16d1316b16..defba235ad 100644
--- a/lib/internal/streams/async_iterator.js
+++ b/lib/internal/streams/async_iterator.js
@@ -1,5 +1,7 @@
'use strict';
+const { Object } = primordials;
+
const finished = require('internal/streams/end-of-stream');
const kLastResolve = Symbol('lastResolve');
diff --git a/lib/internal/streams/lazy_transform.js b/lib/internal/streams/lazy_transform.js
index 7fc7f899c6..0036bf306c 100644
--- a/lib/internal/streams/lazy_transform.js
+++ b/lib/internal/streams/lazy_transform.js
@@ -3,6 +3,8 @@
// for the stream, one conventional and one non-conventional.
'use strict';
+const { Object } = primordials;
+
const stream = require('stream');
const {
diff --git a/lib/internal/streams/legacy.js b/lib/internal/streams/legacy.js
index 44ebfc6bd9..06e48e8b15 100644
--- a/lib/internal/streams/legacy.js
+++ b/lib/internal/streams/legacy.js
@@ -1,5 +1,7 @@
'use strict';
+const { Object } = primordials;
+
const EE = require('events');
function Stream() {
diff --git a/lib/internal/timers.js b/lib/internal/timers.js
index 0c7388b7bb..aef099b4b9 100644
--- a/lib/internal/timers.js
+++ b/lib/internal/timers.js
@@ -72,7 +72,7 @@
// timers within (or creation of a new list). However, these operations combined
// have shown to be trivial in comparison to other timers architectures.
-const { Math, Reflect } = primordials;
+const { Math, Object, Reflect } = primordials;
const {
scheduleTimer,
diff --git a/lib/internal/tls.js b/lib/internal/tls.js
index 4e468a2dd7..80f6d80e18 100644
--- a/lib/internal/tls.js
+++ b/lib/internal/tls.js
@@ -1,5 +1,7 @@
'use strict';
+const { Object } = primordials;
+
// Example:
// C=US\nST=CA\nL=SF\nO=Joyent\nOU=Node.js\nCN=ca1\nemailAddress=ry@clouds.org
function parseCertString(s) {
diff --git a/lib/internal/trace_events_async_hooks.js b/lib/internal/trace_events_async_hooks.js
index 3b69a85fab..4485b7a8c8 100644
--- a/lib/internal/trace_events_async_hooks.js
+++ b/lib/internal/trace_events_async_hooks.js
@@ -1,9 +1,10 @@
'use strict';
+const { Object, SafeMap, SafeSet } = primordials;
+
const { trace } = internalBinding('trace_events');
const async_wrap = internalBinding('async_wrap');
const async_hooks = require('async_hooks');
-const { SafeMap, SafeSet } = primordials;
// Use small letters such that chrome://tracing groups by the name.
// The behavior is not only useful but the same as the events emitted using
diff --git a/lib/internal/url.js b/lib/internal/url.js
index 442c164829..a920511df4 100644
--- a/lib/internal/url.js
+++ b/lib/internal/url.js
@@ -1,6 +1,6 @@
'use strict';
-const { Reflect } = primordials;
+const { Object, Reflect } = primordials;
const { inspect } = require('internal/util/inspect');
const {
diff --git a/lib/internal/util.js b/lib/internal/util.js
index e7dca9a23c..82c42e2772 100644
--- a/lib/internal/util.js
+++ b/lib/internal/util.js
@@ -1,6 +1,6 @@
'use strict';
-const { Reflect } = primordials;
+const { Object, Reflect } = primordials;
const {
ERR_INVALID_ARG_TYPE,
@@ -33,10 +33,6 @@ function isError(e) {
return isNativeError(e) || e instanceof Error;
}
-function objectToString(o) {
- return Object.prototype.toString.call(o);
-}
-
// Keep a list of deprecation codes that have been warned on so we only warn on
// each one once.
const codesWarned = {};
@@ -402,7 +398,6 @@ module.exports = {
isInsideNodeModules,
join,
normalizeEncoding,
- objectToString,
once,
promisify,
spliceOne,
diff --git a/lib/internal/util/inspector.js b/lib/internal/util/inspector.js
index 579f93d540..70868e7324 100644
--- a/lib/internal/util/inspector.js
+++ b/lib/internal/util/inspector.js
@@ -1,5 +1,7 @@
'use strict';
+const { Object } = primordials;
+
let session;
function sendInspectorCommand(cb, onError) {
const { hasInspector } = internalBinding('config');
diff --git a/lib/internal/util/types.js b/lib/internal/util/types.js
index 28ef7f27a6..3f05ad06ac 100644
--- a/lib/internal/util/types.js
+++ b/lib/internal/util/types.js
@@ -1,6 +1,6 @@
'use strict';
-const { uncurryThis } = primordials;
+const { Object, uncurryThis } = primordials;
const TypedArrayPrototype = Object.getPrototypeOf(Uint8Array.prototype);
diff --git a/lib/internal/vm/source_text_module.js b/lib/internal/vm/source_text_module.js
index 6840b4281f..1c9e6da4c3 100644
--- a/lib/internal/vm/source_text_module.js
+++ b/lib/internal/vm/source_text_module.js
@@ -1,5 +1,7 @@
'use strict';
+const { Object, SafePromise } = primordials;
+
const { isModuleNamespaceObject } = require('util').types;
const { URL } = require('internal/url');
const { isContext } = internalBinding('contextify');
@@ -17,7 +19,6 @@ const {
customInspectSymbol,
emitExperimentalWarning
} = require('internal/util');
-const { SafePromise } = primordials;
const {
validateInt32,
validateUint32,
diff --git a/lib/internal/worker.js b/lib/internal/worker.js
index c0a2baa869..53e3c7668c 100644
--- a/lib/internal/worker.js
+++ b/lib/internal/worker.js
@@ -1,5 +1,7 @@
'use strict';
+const { Object } = primordials;
+
const EventEmitter = require('events');
const assert = require('internal/assert');
const path = require('path');
diff --git a/lib/internal/worker/io.js b/lib/internal/worker/io.js
index ece0f2741a..04f8f9ad59 100644
--- a/lib/internal/worker/io.js
+++ b/lib/internal/worker/io.js
@@ -1,5 +1,7 @@
'use strict';
+const { Object } = primordials;
+
const {
handle_onclose: handleOnCloseSymbol,
oninit: onInitSymbol
diff --git a/lib/net.js b/lib/net.js
index d3b712ce9c..ffcf9290b3 100644
--- a/lib/net.js
+++ b/lib/net.js
@@ -21,6 +21,8 @@
'use strict';
+const { Object } = primordials;
+
const EventEmitter = require('events');
const stream = require('stream');
const { inspect } = require('internal/util/inspect');
diff --git a/lib/os.js b/lib/os.js
index af97f40e57..d312c7d298 100644
--- a/lib/os.js
+++ b/lib/os.js
@@ -21,6 +21,8 @@
'use strict';
+const { Object } = primordials;
+
const { safeGetenv } = internalBinding('credentials');
const constants = internalBinding('constants').os;
const { deprecate } = require('internal/util');
diff --git a/lib/perf_hooks.js b/lib/perf_hooks.js
index 6345bc7a46..e090ef47c1 100644
--- a/lib/perf_hooks.js
+++ b/lib/perf_hooks.js
@@ -1,5 +1,7 @@
'use strict';
+const { Object } = primordials;
+
const {
ELDHistogram: _ELDHistogram,
PerformanceEntry,
diff --git a/lib/querystring.js b/lib/querystring.js
index 8d97e288c1..a09dc7d426 100644
--- a/lib/querystring.js
+++ b/lib/querystring.js
@@ -23,6 +23,8 @@
'use strict';
+const { Object } = primordials;
+
const { Buffer } = require('buffer');
const {
encodeStr,
diff --git a/lib/readline.js b/lib/readline.js
index e621cde309..250be8ca76 100644
--- a/lib/readline.js
+++ b/lib/readline.js
@@ -27,7 +27,7 @@
'use strict';
-const { Math } = primordials;
+const { Math, Object } = primordials;
const {
ERR_INVALID_CURSOR_POS,
diff --git a/lib/repl.js b/lib/repl.js
index 78bcbbb608..7140e1b56c 100644
--- a/lib/repl.js
+++ b/lib/repl.js
@@ -42,7 +42,7 @@
'use strict';
-const { Math } = primordials;
+const { Math, Object, ObjectPrototype } = primordials;
const {
builtinLibs,
@@ -116,13 +116,6 @@ try {
// Hack for repl require to work properly with node_modules folders
module.paths = CJSModule._nodeModulePaths(module.filename);
-// If obj.hasOwnProperty has been overridden, then calling
-// obj.hasOwnProperty(prop) will break.
-// See: https://github.com/joyent/node/issues/1707
-function hasOwnProperty(obj, prop) {
- return Object.prototype.hasOwnProperty.call(obj, prop);
-}
-
// This is the default "writer" value, if none is passed in the REPL options,
// and it can be overridden by custom print functions, such as `probe` or
// `eyes.js`.
@@ -1263,7 +1256,7 @@ function complete(line, callback) {
group.sort();
for (var j = group.length - 1; j >= 0; j--) {
c = group[j];
- if (!hasOwnProperty(uniq, c)) {
+ if (!ObjectPrototype.hasOwnProperty(uniq, c)) {
completions.unshift(c);
uniq[c] = true;
}
diff --git a/lib/stream.js b/lib/stream.js
index 97c86f7d6f..4918434167 100644
--- a/lib/stream.js
+++ b/lib/stream.js
@@ -21,6 +21,8 @@
'use strict';
+const { Object } = primordials;
+
const { Buffer } = require('buffer');
const pipeline = require('internal/streams/pipeline');
const eos = require('internal/streams/end-of-stream');
diff --git a/lib/string_decoder.js b/lib/string_decoder.js
index b460da1984..fec30beb0a 100644
--- a/lib/string_decoder.js
+++ b/lib/string_decoder.js
@@ -21,6 +21,8 @@
'use strict';
+const { Object } = primordials;
+
const { Buffer } = require('buffer');
const {
kIncompleteCharactersStart,
diff --git a/lib/tty.js b/lib/tty.js
index aef2d6c54e..9e7d7dbb31 100644
--- a/lib/tty.js
+++ b/lib/tty.js
@@ -21,6 +21,8 @@
'use strict';
+const { Object } = primordials;
+
const net = require('net');
const { TTY, isTTY } = internalBinding('tty_wrap');
const errors = require('internal/errors');
diff --git a/lib/url.js b/lib/url.js
index eb60fe477f..be483ae2bc 100644
--- a/lib/url.js
+++ b/lib/url.js
@@ -21,9 +21,10 @@
'use strict';
+const { Object, SafeSet } = primordials;
+
const { toASCII } = require('internal/idna');
const { encodeStr, hexTable } = require('internal/querystring');
-const { SafeSet } = primordials;
const {
ERR_INVALID_ARG_TYPE
diff --git a/lib/util.js b/lib/util.js
index 4b35784dc4..74269f83b8 100644
--- a/lib/util.js
+++ b/lib/util.js
@@ -21,7 +21,7 @@
'use strict';
-const { ObjectPrototype, Reflect } = primordials;
+const { Object, ObjectPrototype, Reflect } = primordials;
const {
codes: {
diff --git a/lib/v8.js b/lib/v8.js
index eb46cd4cc6..efce85533d 100644
--- a/lib/v8.js
+++ b/lib/v8.js
@@ -14,6 +14,8 @@
'use strict';
+const { ObjectPrototype } = primordials;
+
const { Buffer } = require('buffer');
const { validateString } = require('internal/validators');
const {
@@ -22,7 +24,6 @@ const {
} = internalBinding('serdes');
const assert = require('internal/assert');
const { copy } = internalBinding('buffer');
-const { objectToString } = require('internal/util');
const { FastBuffer } = require('internal/buffer');
const { toPathIfFileURL } = require('internal/url');
const { validatePath } = require('internal/fs/utils');
@@ -193,7 +194,7 @@ const arrayBufferViewTypeToIndex = new Map();
{
const dummy = new ArrayBuffer();
for (const [i, ctor] of arrayBufferViewTypes.entries()) {
- const tag = objectToString(new ctor(dummy));
+ const tag = ObjectPrototype.toString(new ctor(dummy));
arrayBufferViewTypeToIndex.set(tag, i);
}
}
@@ -212,7 +213,7 @@ class DefaultSerializer extends Serializer {
if (abView.constructor === Buffer) {
i = bufferConstructorIndex;
} else {
- const tag = objectToString(abView);
+ const tag = ObjectPrototype.toString(abView);
i = arrayBufferViewTypeToIndex.get(tag);
if (i === undefined) {
diff --git a/lib/zlib.js b/lib/zlib.js
index 1d19210d70..a8a1e09a70 100644
--- a/lib/zlib.js
+++ b/lib/zlib.js
@@ -21,7 +21,7 @@
'use strict';
-const { Math } = primordials;
+const { Math, Object } = primordials;
const {
codes: {
diff --git a/src/node.cc b/src/node.cc
index 6e2327ef51..adf4a83209 100644
--- a/src/node.cc
+++ b/src/node.cc
@@ -381,12 +381,14 @@ MaybeLocal<Value> StartExecution(Environment* env, const char* main_script_id) {
env->process_string(),
env->require_string(),
env->internal_binding_string(),
+ env->primordials_string(),
FIXED_ONE_BYTE_STRING(env->isolate(), "markBootstrapComplete")};
std::vector<Local<Value>> arguments = {
env->process_object(),
env->native_module_require(),
env->internal_binding_loader(),
+ env->primordials(),
env->NewFunctionTemplate(MarkBootstrapComplete)
->GetFunction(env->context())
.ToLocalChecked()};