aboutsummaryrefslogtreecommitdiff
path: root/lib/internal
diff options
context:
space:
mode:
Diffstat (limited to 'lib/internal')
-rw-r--r--lib/internal/child_process.js9
-rw-r--r--lib/internal/console/constructor.js7
-rw-r--r--lib/internal/dns/utils.js7
-rw-r--r--lib/internal/errors.js3
-rw-r--r--lib/internal/fixed_queue.js4
-rw-r--r--lib/internal/fs/streams.js1
-rw-r--r--lib/internal/fs/utils.js3
-rw-r--r--lib/internal/http2/compat.js3
-rw-r--r--lib/internal/http2/core.js6
-rw-r--r--lib/internal/http2/util.js5
-rw-r--r--lib/internal/modules/cjs/loader.js11
-rw-r--r--lib/internal/per_context/primordials.js9
-rw-r--r--lib/internal/policy/manifest.js3
-rw-r--r--lib/internal/priority_queue.js4
-rw-r--r--lib/internal/process/main_thread_only.js6
-rw-r--r--lib/internal/process/per_thread.js3
-rw-r--r--lib/internal/process/task_queues.js1
-rw-r--r--lib/internal/process/warning.js6
-rw-r--r--lib/internal/querystring.js4
-rw-r--r--lib/internal/stream_base_commons.js4
-rw-r--r--lib/internal/streams/pipeline.js6
-rw-r--r--lib/internal/tls.js3
-rw-r--r--lib/internal/url.js1
-rw-r--r--lib/internal/util.js6
-rw-r--r--lib/internal/util/comparisons.js3
-rw-r--r--lib/internal/util/inspect.js1
-rw-r--r--lib/internal/vm/module.js3
-rw-r--r--lib/internal/worker.js3
28 files changed, 84 insertions, 41 deletions
diff --git a/lib/internal/child_process.js b/lib/internal/child_process.js
index 05966f9e40..3836ee8e3d 100644
--- a/lib/internal/child_process.js
+++ b/lib/internal/child_process.js
@@ -1,6 +1,7 @@
'use strict';
const {
+ ArrayIsArray,
ObjectDefineProperty,
ObjectSetPrototypeOf,
} = primordials;
@@ -357,7 +358,7 @@ ChildProcess.prototype.spawn = function(options) {
// Let child process know about opened IPC channel
if (options.envPairs === undefined)
options.envPairs = [];
- else if (!Array.isArray(options.envPairs)) {
+ else if (!ArrayIsArray(options.envPairs)) {
throw new ERR_INVALID_ARG_TYPE('options.envPairs',
'Array',
options.envPairs);
@@ -370,7 +371,7 @@ ChildProcess.prototype.spawn = function(options) {
validateString(options.file, 'options.file');
this.spawnfile = options.file;
- if (Array.isArray(options.args))
+ if (ArrayIsArray(options.args))
this.spawnargs = options.args;
else if (options.args === undefined)
this.spawnargs = [];
@@ -613,7 +614,7 @@ function setupChannel(target, channel, serializationMode) {
}
}
- assert(Array.isArray(target._handleQueue));
+ assert(ArrayIsArray(target._handleQueue));
const queue = target._handleQueue;
target._handleQueue = null;
@@ -912,7 +913,7 @@ function getValidStdio(stdio, sync) {
// Replace shortcut with an array
if (typeof stdio === 'string') {
stdio = stdioStringToArray(stdio);
- } else if (!Array.isArray(stdio)) {
+ } else if (!ArrayIsArray(stdio)) {
throw new ERR_INVALID_OPT_VALUE('stdio', inspect(stdio));
}
diff --git a/lib/internal/console/constructor.js b/lib/internal/console/constructor.js
index 43ae0eee41..0e96f16dfd 100644
--- a/lib/internal/console/constructor.js
+++ b/lib/internal/console/constructor.js
@@ -4,6 +4,8 @@
// console. It's exported for backwards compatibility.
const {
+ ArrayFrom,
+ ArrayIsArray,
MathFloor,
ObjectDefineProperties,
ObjectDefineProperty,
@@ -44,11 +46,6 @@ const kSecond = 1000;
const kMinute = 60 * kSecond;
const kHour = 60 * kMinute;
-const {
- isArray: ArrayIsArray,
- from: ArrayFrom,
-} = Array;
-
// Lazy loaded for startup performance.
let cliTable;
diff --git a/lib/internal/dns/utils.js b/lib/internal/dns/utils.js
index 226d134680..18ad6bfad7 100644
--- a/lib/internal/dns/utils.js
+++ b/lib/internal/dns/utils.js
@@ -1,4 +1,9 @@
'use strict';
+
+const {
+ ArrayIsArray,
+} = primordials;
+
const errors = require('internal/errors');
const { isIP } = require('internal/net');
const {
@@ -38,7 +43,7 @@ class Resolver {
}
setServers(servers) {
- if (!Array.isArray(servers)) {
+ if (!ArrayIsArray(servers)) {
throw new ERR_INVALID_ARG_TYPE('servers', 'Array', servers);
}
diff --git a/lib/internal/errors.js b/lib/internal/errors.js
index a5155d936b..7dd976e299 100644
--- a/lib/internal/errors.js
+++ b/lib/internal/errors.js
@@ -11,6 +11,7 @@
// message may change, the code should not.
const {
+ ArrayIsArray,
MathAbs,
ObjectDefineProperty,
ObjectKeys,
@@ -608,7 +609,7 @@ function isStackOverflowError(err) {
function oneOf(expected, thing) {
assert(typeof thing === 'string', '`thing` has to be of type string');
- if (Array.isArray(expected)) {
+ if (ArrayIsArray(expected)) {
const len = expected.length;
assert(len > 0,
'At least one expected value needs to be specified');
diff --git a/lib/internal/fixed_queue.js b/lib/internal/fixed_queue.js
index a073ab7fc3..d3ffbc2a1e 100644
--- a/lib/internal/fixed_queue.js
+++ b/lib/internal/fixed_queue.js
@@ -1,5 +1,9 @@
'use strict';
+const {
+ Array,
+} = primordials;
+
// Currently optimal queue size, tested on V8 6.0 - 6.6. Must be power of two.
const kSize = 2048;
const kMask = kSize - 1;
diff --git a/lib/internal/fs/streams.js b/lib/internal/fs/streams.js
index c8447191b5..6f274d8419 100644
--- a/lib/internal/fs/streams.js
+++ b/lib/internal/fs/streams.js
@@ -1,6 +1,7 @@
'use strict';
const {
+ Array,
MathMin,
ObjectDefineProperty,
ObjectSetPrototypeOf,
diff --git a/lib/internal/fs/utils.js b/lib/internal/fs/utils.js
index 6a4717e664..2aaf267987 100644
--- a/lib/internal/fs/utils.js
+++ b/lib/internal/fs/utils.js
@@ -1,6 +1,7 @@
'use strict';
const {
+ ArrayIsArray,
ObjectSetPrototypeOf,
ReflectOwnKeys,
} = primordials;
@@ -541,7 +542,7 @@ const getValidatedPath = hideStackFrames((fileURLOrPath, propName = 'path') => {
});
const validateBufferArray = hideStackFrames((buffers, propName = 'buffers') => {
- if (!Array.isArray(buffers))
+ if (!ArrayIsArray(buffers))
throw new ERR_INVALID_ARG_TYPE(propName, 'ArrayBufferView[]', buffers);
for (let i = 0; i < buffers.length; i++) {
diff --git a/lib/internal/http2/compat.js b/lib/internal/http2/compat.js
index edd3d64ccf..b8d7dadb94 100644
--- a/lib/internal/http2/compat.js
+++ b/lib/internal/http2/compat.js
@@ -1,6 +1,7 @@
'use strict';
const {
+ ArrayIsArray,
ObjectAssign,
ObjectCreate,
ObjectKeys,
@@ -617,7 +618,7 @@ class Http2ServerResponse extends Stream {
headers = statusMessage;
let i;
- if (Array.isArray(headers)) {
+ if (ArrayIsArray(headers)) {
for (i = 0; i < headers.length; i++) {
const header = headers[i];
this[kSetHeader](header[0], header[1]);
diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js
index 94b66d424e..4060aff75e 100644
--- a/lib/internal/http2/core.js
+++ b/lib/internal/http2/core.js
@@ -3,6 +3,8 @@
/* eslint-disable no-use-before-define */
const {
+ ArrayFrom,
+ ArrayIsArray,
MathMin,
ObjectAssign,
ObjectCreate,
@@ -948,7 +950,7 @@ function setupHandle(socket, type, options) {
this.settings(settings);
if (type === NGHTTP2_SESSION_SERVER &&
- Array.isArray(options.origins)) {
+ ArrayIsArray(options.origins)) {
this.origin(...options.origins);
}
@@ -1105,7 +1107,7 @@ class Http2Session extends EventEmitter {
get originSet() {
if (!this.encrypted || this.destroyed)
return undefined;
- return Array.from(initOriginSet(this));
+ return ArrayFrom(initOriginSet(this));
}
// True if the Http2Session is still waiting for the socket to connect
diff --git a/lib/internal/http2/util.js b/lib/internal/http2/util.js
index 482ae8546a..b43d6d421a 100644
--- a/lib/internal/http2/util.js
+++ b/lib/internal/http2/util.js
@@ -1,6 +1,7 @@
'use strict';
const {
+ ArrayIsArray,
MathMax,
ObjectCreate,
ObjectKeys,
@@ -449,7 +450,7 @@ function mapToHeaders(map,
continue;
key = key.toLowerCase();
isSingleValueHeader = kSingleValueHeaders.has(key);
- isArray = Array.isArray(value);
+ isArray = ArrayIsArray(value);
if (isArray) {
switch (value.length) {
case 0:
@@ -513,7 +514,7 @@ const assertIsObject = hideStackFrames((value, name, types) => {
if (value !== undefined &&
(value === null ||
typeof value !== 'object' ||
- Array.isArray(value))) {
+ ArrayIsArray(value))) {
throw new ERR_INVALID_ARG_TYPE(name, types || 'Object', value);
}
});
diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js
index 671006f9a9..0b98fb9d4f 100644
--- a/lib/internal/modules/cjs/loader.js
+++ b/lib/internal/modules/cjs/loader.js
@@ -22,6 +22,7 @@
'use strict';
const {
+ ArrayIsArray,
JSONParse,
ObjectCreate,
ObjectDefineProperty,
@@ -464,7 +465,7 @@ function trySelf(paths, exts, isMain, trailingSlash, request) {
function isConditionalDotExportSugar(exports, basePath) {
if (typeof exports === 'string')
return true;
- if (Array.isArray(exports))
+ if (ArrayIsArray(exports))
return true;
if (typeof exports !== 'object')
return false;
@@ -572,9 +573,9 @@ function resolveExportsTarget(pkgPath, target, subpath, basePath, mappingKey) {
}
}
}
- } else if (Array.isArray(target)) {
+ } else if (ArrayIsArray(target)) {
for (const targetValue of target) {
- if (Array.isArray(targetValue)) continue;
+ if (ArrayIsArray(targetValue)) continue;
try {
return resolveExportsTarget(pkgPath, targetValue, subpath, basePath,
mappingKey);
@@ -967,7 +968,7 @@ Module._resolveFilename = function(request, parent, isMain, options) {
let paths;
if (typeof options === 'object' && options !== null) {
- if (Array.isArray(options.paths)) {
+ if (ArrayIsArray(options.paths)) {
const isRelative = request.startsWith('./') ||
request.startsWith('../') ||
((isWindows && request.startsWith('.\\')) ||
@@ -1330,7 +1331,7 @@ Module._initPaths = function() {
};
Module._preloadModules = function(requests) {
- if (!Array.isArray(requests))
+ if (!ArrayIsArray(requests))
return;
// Preloaded modules have a dummy parent module which is deemed to exist
diff --git a/lib/internal/per_context/primordials.js b/lib/internal/per_context/primordials.js
index 6957019490..9e17b3541c 100644
--- a/lib/internal/per_context/primordials.js
+++ b/lib/internal/per_context/primordials.js
@@ -13,7 +13,6 @@
// by the native module compiler.
const ReflectApply = Reflect.apply;
-const ReflectConstruct = Reflect.construct;
// This function is borrowed from the function with the same name on V8 Extras'
// `utils` object. V8 implements Reflect.apply very efficiently in conjunction
@@ -120,13 +119,7 @@ primordials.SafePromise = makeSafe(
'WeakSet',
].forEach((name) => {
const original = global[name];
- primordials[name] = Object.setPrototypeOf({
- [name]: function(...args) {
- return new.target ?
- ReflectConstruct(original, args, new.target) :
- ReflectApply(original, this, args);
- }
- }[name], null);
+ primordials[name] = original;
copyPropsRenamed(original, primordials, name);
copyPrototype(original.prototype, primordials, `${name}Prototype`);
});
diff --git a/lib/internal/policy/manifest.js b/lib/internal/policy/manifest.js
index d078ed092e..02cf0743d7 100644
--- a/lib/internal/policy/manifest.js
+++ b/lib/internal/policy/manifest.js
@@ -1,6 +1,7 @@
'use strict';
const {
+ ArrayIsArray,
Map,
MapPrototypeSet,
ObjectEntries,
@@ -137,7 +138,7 @@ class Manifest {
if (dependencyMap === null || dependencyMap === undefined) {
dependencyMap = {};
}
- if (typeof dependencyMap === 'object' && !Array.isArray(dependencyMap)) {
+ if (typeof dependencyMap === 'object' && !ArrayIsArray(dependencyMap)) {
/**
* @returns {true | URL}
*/
diff --git a/lib/internal/priority_queue.js b/lib/internal/priority_queue.js
index ec8bbaea41..afd2cef643 100644
--- a/lib/internal/priority_queue.js
+++ b/lib/internal/priority_queue.js
@@ -1,5 +1,9 @@
'use strict';
+const {
+ Array,
+} = primordials;
+
const kCompare = Symbol('compare');
const kHeap = Symbol('heap');
const kSetPosition = Symbol('setPosition');
diff --git a/lib/internal/process/main_thread_only.js b/lib/internal/process/main_thread_only.js
index a610395be9..ab56500744 100644
--- a/lib/internal/process/main_thread_only.js
+++ b/lib/internal/process/main_thread_only.js
@@ -4,6 +4,10 @@
// run in the main thread
const {
+ ArrayIsArray,
+} = primordials;
+
+const {
errnoException,
codes: {
ERR_INVALID_ARG_TYPE,
@@ -74,7 +78,7 @@ function wrapPosixCredentialSetters(credentials) {
}
function setgroups(groups) {
- if (!Array.isArray(groups)) {
+ if (!ArrayIsArray(groups)) {
throw new ERR_INVALID_ARG_TYPE('groups', 'Array', groups);
}
for (let i = 0; i < groups.length; i++) {
diff --git a/lib/internal/process/per_thread.js b/lib/internal/process/per_thread.js
index 624601303a..7b1cd9eabe 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 {
+ ArrayIsArray,
ObjectDefineProperties,
ObjectDefineProperty,
ObjectFreeze,
@@ -114,7 +115,7 @@ function wrapProcessMethods(binding) {
_hrtime(hrValues);
if (time !== undefined) {
- if (!Array.isArray(time)) {
+ if (!ArrayIsArray(time)) {
throw new ERR_INVALID_ARG_TYPE('time', 'Array', time);
}
if (time.length !== 2) {
diff --git a/lib/internal/process/task_queues.js b/lib/internal/process/task_queues.js
index 8ad9086a41..1abbfa78f8 100644
--- a/lib/internal/process/task_queues.js
+++ b/lib/internal/process/task_queues.js
@@ -1,6 +1,7 @@
'use strict';
const {
+ Array,
FunctionPrototypeBind,
} = primordials;
diff --git a/lib/internal/process/warning.js b/lib/internal/process/warning.js
index 67a553e21a..cf744cf0d5 100644
--- a/lib/internal/process/warning.js
+++ b/lib/internal/process/warning.js
@@ -1,5 +1,9 @@
'use strict';
+const {
+ ArrayIsArray,
+} = primordials;
+
const { ERR_INVALID_ARG_TYPE } = require('internal/errors').codes;
// Lazily loaded
@@ -84,7 +88,7 @@ function onWarning(warning) {
// process.emitWarning(str[, options])
function emitWarning(warning, type, code, ctor, now) {
let detail;
- if (type !== null && typeof type === 'object' && !Array.isArray(type)) {
+ if (type !== null && typeof type === 'object' && !ArrayIsArray(type)) {
ctor = type.ctor;
code = type.code;
if (typeof type.detail === 'string')
diff --git a/lib/internal/querystring.js b/lib/internal/querystring.js
index ecb4e072d8..7df1c495c6 100644
--- a/lib/internal/querystring.js
+++ b/lib/internal/querystring.js
@@ -1,5 +1,9 @@
'use strict';
+const {
+ Array,
+} = primordials;
+
const { ERR_INVALID_URI } = require('internal/errors').codes;
const hexTable = new Array(256);
diff --git a/lib/internal/stream_base_commons.js b/lib/internal/stream_base_commons.js
index 95430ff738..504de5fc57 100644
--- a/lib/internal/stream_base_commons.js
+++ b/lib/internal/stream_base_commons.js
@@ -1,5 +1,9 @@
'use strict';
+const {
+ Array,
+} = primordials;
+
const { Buffer } = require('buffer');
const { FastBuffer } = require('internal/buffer');
const {
diff --git a/lib/internal/streams/pipeline.js b/lib/internal/streams/pipeline.js
index 798745a110..0c46460510 100644
--- a/lib/internal/streams/pipeline.js
+++ b/lib/internal/streams/pipeline.js
@@ -3,6 +3,10 @@
'use strict';
+const {
+ ArrayIsArray,
+} = primordials;
+
let eos;
const { once } = require('internal/util');
@@ -65,7 +69,7 @@ function popCallback(streams) {
function pipeline(...streams) {
const callback = popCallback(streams);
- if (Array.isArray(streams[0])) streams = streams[0];
+ if (ArrayIsArray(streams[0])) streams = streams[0];
if (streams.length < 2) {
throw new ERR_MISSING_ARGS('streams');
diff --git a/lib/internal/tls.js b/lib/internal/tls.js
index ee43801638..d7370ad52c 100644
--- a/lib/internal/tls.js
+++ b/lib/internal/tls.js
@@ -1,6 +1,7 @@
'use strict';
const {
+ ArrayIsArray,
ObjectCreate,
} = primordials;
@@ -15,7 +16,7 @@ function parseCertString(s) {
const key = parts[i].slice(0, sepIndex);
const value = parts[i].slice(sepIndex + 1);
if (key in out) {
- if (!Array.isArray(out[key])) {
+ if (!ArrayIsArray(out[key])) {
out[key] = [out[key]];
}
out[key].push(value);
diff --git a/lib/internal/url.js b/lib/internal/url.js
index b4c047be52..a30bcf5b98 100644
--- a/lib/internal/url.js
+++ b/lib/internal/url.js
@@ -1,6 +1,7 @@
'use strict';
const {
+ Array,
ObjectCreate,
ObjectDefineProperties,
ObjectDefineProperty,
diff --git a/lib/internal/util.js b/lib/internal/util.js
index 30302c79a8..1ff25dbc7d 100644
--- a/lib/internal/util.js
+++ b/lib/internal/util.js
@@ -1,6 +1,8 @@
'use strict';
const {
+ ArrayFrom,
+ ArrayIsArray,
ObjectCreate,
ObjectDefineProperties,
ObjectDefineProperty,
@@ -184,7 +186,7 @@ function filterDuplicateStrings(items, low) {
map.set(key, item);
}
}
- return Array.from(map.values()).sort();
+ return ArrayFrom(map.values()).sort();
}
function cachedResult(fn) {
@@ -361,7 +363,7 @@ function isInsideNodeModules() {
// Iterate over all stack frames and look for the first one not coming
// from inside Node.js itself:
- if (Array.isArray(stack)) {
+ if (ArrayIsArray(stack)) {
for (const frame of stack) {
const filename = frame.getFileName();
// If a filename does not start with / or contain \,
diff --git a/lib/internal/util/comparisons.js b/lib/internal/util/comparisons.js
index 3af44f9bf5..b278421717 100644
--- a/lib/internal/util/comparisons.js
+++ b/lib/internal/util/comparisons.js
@@ -1,6 +1,7 @@
'use strict';
const {
+ ArrayIsArray,
BigIntPrototypeValueOf,
BooleanPrototypeValueOf,
DatePrototypeGetTime,
@@ -163,7 +164,7 @@ function innerDeepEqual(val1, val2, strict, memos) {
if (val1Tag !== val2Tag) {
return false;
}
- if (Array.isArray(val1)) {
+ if (ArrayIsArray(val1)) {
// Check for sparse arrays and general fast path
if (val1.length !== val2.length) {
return false;
diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js
index 0b02e9be51..89237a09a5 100644
--- a/lib/internal/util/inspect.js
+++ b/lib/internal/util/inspect.js
@@ -1,6 +1,7 @@
'use strict';
const {
+ Array,
ArrayIsArray,
BigIntPrototypeValueOf,
BooleanPrototypeValueOf,
diff --git a/lib/internal/vm/module.js b/lib/internal/vm/module.js
index c97556ceb8..88a276e217 100644
--- a/lib/internal/vm/module.js
+++ b/lib/internal/vm/module.js
@@ -1,6 +1,7 @@
'use strict';
const {
+ ArrayIsArray,
ObjectCreate,
ObjectDefineProperty,
Symbol,
@@ -350,7 +351,7 @@ class SourceTextModule extends Module {
class SyntheticModule extends Module {
constructor(exportNames, evaluateCallback, options = {}) {
- if (!Array.isArray(exportNames) ||
+ if (!ArrayIsArray(exportNames) ||
exportNames.some((e) => typeof e !== 'string')) {
throw new ERR_INVALID_ARG_TYPE('exportNames', 'Array of strings',
exportNames);
diff --git a/lib/internal/worker.js b/lib/internal/worker.js
index 699bf24346..621dfa7769 100644
--- a/lib/internal/worker.js
+++ b/lib/internal/worker.js
@@ -3,6 +3,7 @@
/* global SharedArrayBuffer */
const {
+ ArrayIsArray,
MathMax,
ObjectCreate,
ObjectEntries,
@@ -79,7 +80,7 @@ class Worker extends EventEmitter {
super();
debug(`[${threadId}] create new worker`, filename, options);
validateString(filename, 'filename');
- if (options.execArgv && !Array.isArray(options.execArgv)) {
+ if (options.execArgv && !ArrayIsArray(options.execArgv)) {
throw new ERR_INVALID_ARG_TYPE('options.execArgv',
'array',
options.execArgv);