lib: enforce the use of Object from primordials
PR-URL: https://github.com/nodejs/node/pull/27146 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gus Caplan <me@gus.host>
This commit is contained in:
parent
9ad5106934
commit
908292cf1f
@ -10,6 +10,8 @@ rules:
|
|||||||
message: "Use `const { JSON } = primordials;` instead of the global."
|
message: "Use `const { JSON } = primordials;` instead of the global."
|
||||||
- name: Math
|
- name: Math
|
||||||
message: "Use `const { Math } = primordials;` instead of the global."
|
message: "Use `const { Math } = primordials;` instead of the global."
|
||||||
|
- name: Object
|
||||||
|
message: "Use `const { Object } = primordials;` instead of the global."
|
||||||
- name: Reflect
|
- name: Reflect
|
||||||
message: "Use `const { Reflect } = primordials;` instead of the global."
|
message: "Use `const { Reflect } = primordials;` instead of the global."
|
||||||
no-restricted-syntax:
|
no-restricted-syntax:
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const net = require('net');
|
const net = require('net');
|
||||||
const EventEmitter = require('events');
|
const EventEmitter = require('events');
|
||||||
const debug = require('internal/util/debuglog').debuglog('http');
|
const debug = require('internal/util/debuglog').debuglog('http');
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const net = require('net');
|
const net = require('net');
|
||||||
const url = require('url');
|
const url = require('url');
|
||||||
const assert = require('internal/assert');
|
const assert = require('internal/assert');
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const Stream = require('stream');
|
const Stream = require('stream');
|
||||||
|
|
||||||
function readStart(socket) {
|
function readStart(socket) {
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { ObjectPrototype } = primordials;
|
const { Object, ObjectPrototype } = primordials;
|
||||||
|
|
||||||
const assert = require('internal/assert');
|
const assert = require('internal/assert');
|
||||||
const Stream = require('stream');
|
const Stream = require('stream');
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const net = require('net');
|
const net = require('net');
|
||||||
const assert = require('internal/assert');
|
const assert = require('internal/assert');
|
||||||
const {
|
const {
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
module.exports = Duplex;
|
module.exports = Duplex;
|
||||||
|
|
||||||
const Readable = require('_stream_readable');
|
const Readable = require('_stream_readable');
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
module.exports = PassThrough;
|
module.exports = PassThrough;
|
||||||
|
|
||||||
const Transform = require('_stream_transform');
|
const Transform = require('_stream_transform');
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
module.exports = Readable;
|
module.exports = Readable;
|
||||||
Readable.ReadableState = ReadableState;
|
Readable.ReadableState = ReadableState;
|
||||||
|
|
||||||
|
@ -63,6 +63,8 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
module.exports = Transform;
|
module.exports = Transform;
|
||||||
const {
|
const {
|
||||||
ERR_METHOD_NOT_IMPLEMENTED,
|
ERR_METHOD_NOT_IMPLEMENTED,
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
module.exports = Writable;
|
module.exports = Writable;
|
||||||
Writable.WritableState = WritableState;
|
Writable.WritableState = WritableState;
|
||||||
|
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const { parseCertString } = require('internal/tls');
|
const { parseCertString } = require('internal/tls');
|
||||||
const { isArrayBufferView } = require('internal/util/types');
|
const { isArrayBufferView } = require('internal/util/types');
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
assertCrypto,
|
assertCrypto,
|
||||||
deprecate
|
deprecate
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const { Buffer } = require('buffer');
|
const { Buffer } = require('buffer');
|
||||||
const { codes: {
|
const { codes: {
|
||||||
ERR_AMBIGUOUS_ARGUMENT,
|
ERR_AMBIGUOUS_ARGUMENT,
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { Math } = primordials;
|
const { Math, Object } = primordials;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
byteLengthUtf8,
|
byteLengthUtf8,
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object, ObjectPrototype } = primordials;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
promisify,
|
promisify,
|
||||||
convertToValidSignal,
|
convertToValidSignal,
|
||||||
@ -515,8 +517,7 @@ function normalizeSpawnArguments(file, args, options) {
|
|||||||
// process.env.NODE_V8_COVERAGE always propagates, making it possible to
|
// process.env.NODE_V8_COVERAGE always propagates, making it possible to
|
||||||
// collect coverage for programs that spawn with white-listed environment.
|
// collect coverage for programs that spawn with white-listed environment.
|
||||||
if (process.env.NODE_V8_COVERAGE &&
|
if (process.env.NODE_V8_COVERAGE &&
|
||||||
!Object.prototype.hasOwnProperty.call(options.env || {},
|
!ObjectPrototype.hasOwnProperty(options.env || {}, 'NODE_V8_COVERAGE')) {
|
||||||
'NODE_V8_COVERAGE')) {
|
|
||||||
env.NODE_V8_COVERAGE = process.env.NODE_V8_COVERAGE;
|
env.NODE_V8_COVERAGE = process.env.NODE_V8_COVERAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
// This module is deprecated in documentation only. Users should be directed
|
// This module is deprecated in documentation only. Users should be directed
|
||||||
// towards using the specific constants exposed by the individual modules on
|
// towards using the specific constants exposed by the individual modules on
|
||||||
// which they are most relevant.
|
// which they are most relevant.
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
assertCrypto,
|
assertCrypto,
|
||||||
deprecate
|
deprecate
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const errors = require('internal/errors');
|
const errors = require('internal/errors');
|
||||||
const {
|
const {
|
||||||
kStateSymbol,
|
kStateSymbol,
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const cares = internalBinding('cares_wrap');
|
const cares = internalBinding('cares_wrap');
|
||||||
const { toASCII } = require('internal/idna');
|
const { toASCII } = require('internal/idna');
|
||||||
const { isIP, isIPv4, isLegalPort } = require('internal/net');
|
const { isIP, isIPv4, isLegalPort } = require('internal/net');
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
// No new pull requests targeting this module will be accepted
|
// No new pull requests targeting this module will be accepted
|
||||||
// unless they address existing, critical bugs.
|
// unless they address existing, critical bugs.
|
||||||
|
|
||||||
const { Reflect } = primordials;
|
const { Object, Reflect } = primordials;
|
||||||
|
|
||||||
const util = require('util');
|
const util = require('util');
|
||||||
const EventEmitter = require('events');
|
const EventEmitter = require('events');
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { Math, Reflect } = primordials;
|
const { Math, Object, Reflect } = primordials;
|
||||||
|
|
||||||
var spliceOne;
|
var spliceOne;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { Math, Reflect } = primordials;
|
const { Math, Object, Reflect } = primordials;
|
||||||
|
|
||||||
const { fs: constants } = internalBinding('constants');
|
const { fs: constants } = internalBinding('constants');
|
||||||
const {
|
const {
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const httpAgent = require('_http_agent');
|
const httpAgent = require('_http_agent');
|
||||||
const { ClientRequest } = require('_http_client');
|
const { ClientRequest } = require('_http_client');
|
||||||
const { methods } = require('_http_common');
|
const { methods } = require('_http_common');
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
require('internal/util').assertCrypto();
|
require('internal/util').assertCrypto();
|
||||||
|
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { Math } = primordials;
|
const { Math, Object } = primordials;
|
||||||
|
|
||||||
const { inspect } = require('internal/util/inspect');
|
const { inspect } = require('internal/util/inspect');
|
||||||
const { codes: {
|
const { codes: {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { FunctionPrototype, Reflect } = primordials;
|
const { FunctionPrototype, Object, Reflect } = primordials;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
ERR_ASYNC_TYPE,
|
ERR_ASYNC_TYPE,
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const { getOptionValue } = require('internal/options');
|
const { getOptionValue } = require('internal/options');
|
||||||
const { Buffer } = require('buffer');
|
const { Buffer } = require('buffer');
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { JSON } = primordials;
|
const { JSON, Object } = primordials;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
errnoException,
|
errnoException,
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const assert = require('internal/assert');
|
const assert = require('internal/assert');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const EventEmitter = require('events');
|
const EventEmitter = require('events');
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const assert = require('internal/assert');
|
const assert = require('internal/assert');
|
||||||
const { fork } = require('child_process');
|
const { fork } = require('child_process');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
@ -8,7 +11,6 @@ const SharedHandle = require('internal/cluster/shared_handle');
|
|||||||
const Worker = require('internal/cluster/worker');
|
const Worker = require('internal/cluster/worker');
|
||||||
const { internal, sendHelper } = require('internal/cluster/utils');
|
const { internal, sendHelper } = require('internal/cluster/utils');
|
||||||
const { ERR_SOCKET_BAD_PORT } = require('internal/errors').codes;
|
const { ERR_SOCKET_BAD_PORT } = require('internal/errors').codes;
|
||||||
const keys = Object.keys;
|
|
||||||
const cluster = new EventEmitter();
|
const cluster = new EventEmitter();
|
||||||
const intercom = new EventEmitter();
|
const intercom = new EventEmitter();
|
||||||
const SCHED_NONE = 1;
|
const SCHED_NONE = 1;
|
||||||
@ -141,7 +143,7 @@ function removeWorker(worker) {
|
|||||||
assert(worker);
|
assert(worker);
|
||||||
delete cluster.workers[worker.id];
|
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.');
|
assert(handles.size === 0, 'Resource leak detected.');
|
||||||
intercom.emit('disconnect');
|
intercom.emit('disconnect');
|
||||||
}
|
}
|
||||||
@ -219,7 +221,7 @@ function emitForkNT(worker) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cluster.disconnect = function(cb) {
|
cluster.disconnect = function(cb) {
|
||||||
const workers = keys(cluster.workers);
|
const workers = Object.keys(cluster.workers);
|
||||||
|
|
||||||
if (workers.length === 0) {
|
if (workers.length === 0) {
|
||||||
process.nextTick(() => intercom.emit('disconnect'));
|
process.nextTick(() => intercom.emit('disconnect'));
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const EventEmitter = require('events');
|
const EventEmitter = require('events');
|
||||||
|
|
||||||
module.exports = Worker;
|
module.exports = Worker;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
// The Console constructor is not actually used to construct the global
|
// The Console constructor is not actually used to construct the global
|
||||||
// console. It's exported for backwards compatibility.
|
// console. It's exported for backwards compatibility.
|
||||||
|
|
||||||
const { ObjectPrototype, Reflect } = primordials;
|
const { Object, ObjectPrototype, Reflect } = primordials;
|
||||||
|
|
||||||
const { trace } = internalBinding('trace_events');
|
const { trace } = internalBinding('trace_events');
|
||||||
const {
|
const {
|
||||||
@ -32,11 +32,6 @@ const kTraceBegin = 'b'.charCodeAt(0);
|
|||||||
const kTraceEnd = 'e'.charCodeAt(0);
|
const kTraceEnd = 'e'.charCodeAt(0);
|
||||||
const kTraceInstant = 'n'.charCodeAt(0);
|
const kTraceInstant = 'n'.charCodeAt(0);
|
||||||
|
|
||||||
const {
|
|
||||||
keys: ObjectKeys,
|
|
||||||
values: ObjectValues,
|
|
||||||
} = Object;
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
isArray: ArrayIsArray,
|
isArray: ArrayIsArray,
|
||||||
from: ArrayFrom,
|
from: ArrayFrom,
|
||||||
@ -414,7 +409,7 @@ const consoleMethods = {
|
|||||||
const depth = v !== null &&
|
const depth = v !== null &&
|
||||||
typeof v === 'object' &&
|
typeof v === 'object' &&
|
||||||
!isArray(v) &&
|
!isArray(v) &&
|
||||||
ObjectKeys(v).length > 2 ? -1 : 0;
|
Object.keys(v).length > 2 ? -1 : 0;
|
||||||
const opt = {
|
const opt = {
|
||||||
depth,
|
depth,
|
||||||
maxArrayLength: 3,
|
maxArrayLength: 3,
|
||||||
@ -478,7 +473,7 @@ const consoleMethods = {
|
|||||||
const map = {};
|
const map = {};
|
||||||
let hasPrimitives = false;
|
let hasPrimitives = false;
|
||||||
const valuesKeyArray = [];
|
const valuesKeyArray = [];
|
||||||
const indexKeyArray = ObjectKeys(tabularData);
|
const indexKeyArray = Object.keys(tabularData);
|
||||||
|
|
||||||
for (; i < indexKeyArray.length; i++) {
|
for (; i < indexKeyArray.length; i++) {
|
||||||
const item = tabularData[indexKeyArray[i]];
|
const item = tabularData[indexKeyArray[i]];
|
||||||
@ -488,7 +483,7 @@ const consoleMethods = {
|
|||||||
hasPrimitives = true;
|
hasPrimitives = true;
|
||||||
valuesKeyArray[i] = _inspect(item);
|
valuesKeyArray[i] = _inspect(item);
|
||||||
} else {
|
} else {
|
||||||
const keys = properties || ObjectKeys(item);
|
const keys = properties || Object.keys(item);
|
||||||
for (const key of keys) {
|
for (const key of keys) {
|
||||||
if (map[key] === undefined)
|
if (map[key] === undefined)
|
||||||
map[key] = [];
|
map[key] = [];
|
||||||
@ -501,8 +496,8 @@ const consoleMethods = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const keys = ObjectKeys(map);
|
const keys = Object.keys(map);
|
||||||
const values = ObjectValues(map);
|
const values = Object.values(map);
|
||||||
if (hasPrimitives) {
|
if (hasPrimitives) {
|
||||||
keys.push(valuesKey);
|
keys.push(valuesKey);
|
||||||
values.push(valuesKeyArray);
|
values.push(valuesKeyArray);
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
// Therefore, the console.Console.prototype is not
|
// Therefore, the console.Console.prototype is not
|
||||||
// in the global console prototype chain anymore.
|
// in the global console prototype chain anymore.
|
||||||
|
|
||||||
const { Reflect } = primordials;
|
const { Object, Reflect } = primordials;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
Console,
|
Console,
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
RSA_PKCS1_OAEP_PADDING,
|
RSA_PKCS1_OAEP_PADDING,
|
||||||
RSA_PKCS1_PADDING
|
RSA_PKCS1_PADDING
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const { Buffer } = require('buffer');
|
const { Buffer } = require('buffer');
|
||||||
const {
|
const {
|
||||||
ERR_CRYPTO_ECDH_INVALID_FORMAT,
|
ERR_CRYPTO_ECDH_INVALID_FORMAT,
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
Hash: _Hash,
|
Hash: _Hash,
|
||||||
Hmac: _Hmac
|
Hmac: _Hmac
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const { AsyncWrap, Providers } = internalBinding('async_wrap');
|
const { AsyncWrap, Providers } = internalBinding('async_wrap');
|
||||||
const {
|
const {
|
||||||
generateKeyPairRSA,
|
generateKeyPairRSA,
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
KeyObject: KeyObjectHandle,
|
KeyObject: KeyObjectHandle,
|
||||||
kKeyTypeSecret,
|
kKeyTypeSecret,
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
ERR_CRYPTO_SIGN_KEY_REQUIRED,
|
ERR_CRYPTO_SIGN_KEY_REQUIRED,
|
||||||
ERR_INVALID_ARG_TYPE,
|
ERR_INVALID_ARG_TYPE,
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
bindDefaultResolver,
|
bindDefaultResolver,
|
||||||
Resolver: CallbackResolver,
|
Resolver: CallbackResolver,
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
// An implementation of the WHATWG Encoding Standard
|
// An implementation of the WHATWG Encoding Standard
|
||||||
// https://encoding.spec.whatwg.org
|
// https://encoding.spec.whatwg.org
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
ERR_ENCODING_INVALID_ENCODED_DATA,
|
ERR_ENCODING_INVALID_ENCODED_DATA,
|
||||||
ERR_ENCODING_NOT_SUPPORTED,
|
ERR_ENCODING_NOT_SUPPORTED,
|
||||||
|
@ -10,13 +10,14 @@
|
|||||||
// value statically and permanently identifies the error. While the error
|
// value statically and permanently identifies the error. While the error
|
||||||
// message may change, the code should not.
|
// message may change, the code should not.
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const kCode = Symbol('code');
|
const kCode = Symbol('code');
|
||||||
const kInfo = Symbol('info');
|
const kInfo = Symbol('info');
|
||||||
const messages = new Map();
|
const messages = new Map();
|
||||||
const codes = {};
|
const codes = {};
|
||||||
|
|
||||||
const { kMaxLength } = internalBinding('buffer');
|
const { kMaxLength } = internalBinding('buffer');
|
||||||
const { defineProperty } = Object;
|
|
||||||
|
|
||||||
let excludedStackFn;
|
let excludedStackFn;
|
||||||
|
|
||||||
@ -100,7 +101,7 @@ class SystemError extends Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
set code(value) {
|
set code(value) {
|
||||||
defineProperty(this, 'code', {
|
Object.defineProperty(this, 'code', {
|
||||||
configurable: true,
|
configurable: true,
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
value,
|
value,
|
||||||
@ -188,7 +189,7 @@ function makeNodeErrorWithCode(Base, key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
set code(value) {
|
set code(value) {
|
||||||
defineProperty(this, 'code', {
|
Object.defineProperty(this, 'code', {
|
||||||
configurable: true,
|
configurable: true,
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
value,
|
value,
|
||||||
@ -234,7 +235,7 @@ function addCodeToName(err, name, code) {
|
|||||||
err.stack;
|
err.stack;
|
||||||
// Reset the name to the actual name.
|
// Reset the name to the actual name.
|
||||||
if (name === 'SystemError') {
|
if (name === 'SystemError') {
|
||||||
defineProperty(err, 'name', {
|
Object.defineProperty(err, 'name', {
|
||||||
value: name,
|
value: name,
|
||||||
enumerable: false,
|
enumerable: false,
|
||||||
writable: true,
|
writable: true,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { Math } = primordials;
|
const { Math, Object } = primordials;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
FSReqCallback,
|
FSReqCallback,
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const { Writable } = require('stream');
|
const { Writable } = require('stream');
|
||||||
const { closeSync, writeSync } = require('fs');
|
const { closeSync, writeSync } = require('fs');
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const errors = require('internal/errors');
|
const errors = require('internal/errors');
|
||||||
const {
|
const {
|
||||||
kFsStatsFieldsNumber,
|
kFsStatsFieldsNumber,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { Reflect } = primordials;
|
const { Object, ObjectPrototype, Reflect } = primordials;
|
||||||
|
|
||||||
const assert = require('internal/assert');
|
const assert = require('internal/assert');
|
||||||
const Stream = require('stream');
|
const Stream = require('stream');
|
||||||
@ -539,7 +539,7 @@ class Http2ServerResponse extends Stream {
|
|||||||
hasHeader(name) {
|
hasHeader(name) {
|
||||||
validateString(name, 'name');
|
validateString(name, 'name');
|
||||||
name = name.trim().toLowerCase();
|
name = name.trim().toLowerCase();
|
||||||
return Object.prototype.hasOwnProperty.call(this[kHeaders], name);
|
return ObjectPrototype.hasOwnProperty(this[kHeaders], name);
|
||||||
}
|
}
|
||||||
|
|
||||||
removeHeader(name) {
|
removeHeader(name) {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
/* eslint-disable no-use-before-define */
|
/* eslint-disable no-use-before-define */
|
||||||
|
|
||||||
const { Math, Reflect } = primordials;
|
const { Math, Object, Reflect } = primordials;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
assertCrypto,
|
assertCrypto,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { Math } = primordials;
|
const { Math, Object } = primordials;
|
||||||
|
|
||||||
const binding = internalBinding('http2');
|
const binding = internalBinding('http2');
|
||||||
const {
|
const {
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
// In worker threads, execute the script sent through the
|
// In worker threads, execute the script sent through the
|
||||||
// message port.
|
// message port.
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
patchProcessObject,
|
patchProcessObject,
|
||||||
setupCoverageHooks,
|
setupCoverageHooks,
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const { validateString } = require('internal/validators');
|
const { validateString } = require('internal/validators');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { pathToFileURL } = require('internal/url');
|
const { pathToFileURL } = require('internal/url');
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { JSON, Reflect } = primordials;
|
const { JSON, Object, Reflect } = primordials;
|
||||||
|
|
||||||
const { NativeModule } = require('internal/bootstrap/loaders');
|
const { NativeModule } = require('internal/bootstrap/loaders');
|
||||||
const { pathToFileURL } = require('internal/url');
|
const { pathToFileURL } = require('internal/url');
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { ModuleWrap } = internalBinding('module_wrap');
|
|
||||||
const {
|
const {
|
||||||
|
Object,
|
||||||
SafeSet,
|
SafeSet,
|
||||||
SafePromise
|
SafePromise
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
|
const { ModuleWrap } = internalBinding('module_wrap');
|
||||||
|
|
||||||
const { decorateErrorStack } = require('internal/util');
|
const { decorateErrorStack } = require('internal/util');
|
||||||
const assert = require('internal/assert');
|
const assert = require('internal/assert');
|
||||||
const resolvedPromise = SafePromise.resolve();
|
const resolvedPromise = SafePromise.resolve();
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
'use strict';
|
'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 {
|
class ERR_INVALID_THIS extends TypeError {
|
||||||
constructor(type) {
|
constructor(type) {
|
||||||
super('Value of "this" must be of ' + type);
|
super('Value of "this" must be of ' + type);
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
// thread and the worker threads.
|
// thread and the worker threads.
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
Object,
|
||||||
RegExpPrototype,
|
RegExpPrototype,
|
||||||
SetPrototype,
|
SetPrototype,
|
||||||
StringPrototype
|
StringPrototype
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { JSON, Reflect } = primordials;
|
const { JSON, Object, Reflect } = primordials;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
ERR_MANIFEST_TDZ,
|
ERR_MANIFEST_TDZ,
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const REPL = require('repl');
|
const REPL = require('repl');
|
||||||
const { kStandaloneREPL } = require('internal/repl/utils');
|
const { kStandaloneREPL } = require('internal/repl/utils');
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const acorn = require('internal/deps/acorn/acorn/dist/acorn');
|
const acorn = require('internal/deps/acorn/acorn/dist/acorn');
|
||||||
const walk = require('internal/deps/acorn/acorn-walk/dist/walk');
|
const walk = require('internal/deps/acorn/acorn-walk/dist/walk');
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const finished = require('internal/streams/end-of-stream');
|
const finished = require('internal/streams/end-of-stream');
|
||||||
|
|
||||||
const kLastResolve = Symbol('lastResolve');
|
const kLastResolve = Symbol('lastResolve');
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
// for the stream, one conventional and one non-conventional.
|
// for the stream, one conventional and one non-conventional.
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const stream = require('stream');
|
const stream = require('stream');
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const EE = require('events');
|
const EE = require('events');
|
||||||
|
|
||||||
function Stream() {
|
function Stream() {
|
||||||
|
@ -72,7 +72,7 @@
|
|||||||
// timers within (or creation of a new list). However, these operations combined
|
// timers within (or creation of a new list). However, these operations combined
|
||||||
// have shown to be trivial in comparison to other timers architectures.
|
// have shown to be trivial in comparison to other timers architectures.
|
||||||
|
|
||||||
const { Math, Reflect } = primordials;
|
const { Math, Object, Reflect } = primordials;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
scheduleTimer,
|
scheduleTimer,
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
// Example:
|
// Example:
|
||||||
// C=US\nST=CA\nL=SF\nO=Joyent\nOU=Node.js\nCN=ca1\nemailAddress=ry@clouds.org
|
// C=US\nST=CA\nL=SF\nO=Joyent\nOU=Node.js\nCN=ca1\nemailAddress=ry@clouds.org
|
||||||
function parseCertString(s) {
|
function parseCertString(s) {
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object, SafeMap, SafeSet } = primordials;
|
||||||
|
|
||||||
const { trace } = internalBinding('trace_events');
|
const { trace } = internalBinding('trace_events');
|
||||||
const async_wrap = internalBinding('async_wrap');
|
const async_wrap = internalBinding('async_wrap');
|
||||||
const async_hooks = require('async_hooks');
|
const async_hooks = require('async_hooks');
|
||||||
const { SafeMap, SafeSet } = primordials;
|
|
||||||
|
|
||||||
// Use small letters such that chrome://tracing groups by the name.
|
// 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
|
// The behavior is not only useful but the same as the events emitted using
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { Reflect } = primordials;
|
const { Object, Reflect } = primordials;
|
||||||
|
|
||||||
const { inspect } = require('internal/util/inspect');
|
const { inspect } = require('internal/util/inspect');
|
||||||
const {
|
const {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { Reflect } = primordials;
|
const { Object, Reflect } = primordials;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
ERR_INVALID_ARG_TYPE,
|
ERR_INVALID_ARG_TYPE,
|
||||||
@ -33,10 +33,6 @@ function isError(e) {
|
|||||||
return isNativeError(e) || e instanceof Error;
|
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
|
// Keep a list of deprecation codes that have been warned on so we only warn on
|
||||||
// each one once.
|
// each one once.
|
||||||
const codesWarned = {};
|
const codesWarned = {};
|
||||||
@ -402,7 +398,6 @@ module.exports = {
|
|||||||
isInsideNodeModules,
|
isInsideNodeModules,
|
||||||
join,
|
join,
|
||||||
normalizeEncoding,
|
normalizeEncoding,
|
||||||
objectToString,
|
|
||||||
once,
|
once,
|
||||||
promisify,
|
promisify,
|
||||||
spliceOne,
|
spliceOne,
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
let session;
|
let session;
|
||||||
function sendInspectorCommand(cb, onError) {
|
function sendInspectorCommand(cb, onError) {
|
||||||
const { hasInspector } = internalBinding('config');
|
const { hasInspector } = internalBinding('config');
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { uncurryThis } = primordials;
|
const { Object, uncurryThis } = primordials;
|
||||||
|
|
||||||
const TypedArrayPrototype = Object.getPrototypeOf(Uint8Array.prototype);
|
const TypedArrayPrototype = Object.getPrototypeOf(Uint8Array.prototype);
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object, SafePromise } = primordials;
|
||||||
|
|
||||||
const { isModuleNamespaceObject } = require('util').types;
|
const { isModuleNamespaceObject } = require('util').types;
|
||||||
const { URL } = require('internal/url');
|
const { URL } = require('internal/url');
|
||||||
const { isContext } = internalBinding('contextify');
|
const { isContext } = internalBinding('contextify');
|
||||||
@ -17,7 +19,6 @@ const {
|
|||||||
customInspectSymbol,
|
customInspectSymbol,
|
||||||
emitExperimentalWarning
|
emitExperimentalWarning
|
||||||
} = require('internal/util');
|
} = require('internal/util');
|
||||||
const { SafePromise } = primordials;
|
|
||||||
const {
|
const {
|
||||||
validateInt32,
|
validateInt32,
|
||||||
validateUint32,
|
validateUint32,
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const EventEmitter = require('events');
|
const EventEmitter = require('events');
|
||||||
const assert = require('internal/assert');
|
const assert = require('internal/assert');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
handle_onclose: handleOnCloseSymbol,
|
handle_onclose: handleOnCloseSymbol,
|
||||||
oninit: onInitSymbol
|
oninit: onInitSymbol
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const EventEmitter = require('events');
|
const EventEmitter = require('events');
|
||||||
const stream = require('stream');
|
const stream = require('stream');
|
||||||
const { inspect } = require('internal/util/inspect');
|
const { inspect } = require('internal/util/inspect');
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const { safeGetenv } = internalBinding('credentials');
|
const { safeGetenv } = internalBinding('credentials');
|
||||||
const constants = internalBinding('constants').os;
|
const constants = internalBinding('constants').os;
|
||||||
const { deprecate } = require('internal/util');
|
const { deprecate } = require('internal/util');
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
ELDHistogram: _ELDHistogram,
|
ELDHistogram: _ELDHistogram,
|
||||||
PerformanceEntry,
|
PerformanceEntry,
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const { Buffer } = require('buffer');
|
const { Buffer } = require('buffer');
|
||||||
const {
|
const {
|
||||||
encodeStr,
|
encodeStr,
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { Math } = primordials;
|
const { Math, Object } = primordials;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
ERR_INVALID_CURSOR_POS,
|
ERR_INVALID_CURSOR_POS,
|
||||||
|
11
lib/repl.js
11
lib/repl.js
@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { Math } = primordials;
|
const { Math, Object, ObjectPrototype } = primordials;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
builtinLibs,
|
builtinLibs,
|
||||||
@ -116,13 +116,6 @@ try {
|
|||||||
// Hack for repl require to work properly with node_modules folders
|
// Hack for repl require to work properly with node_modules folders
|
||||||
module.paths = CJSModule._nodeModulePaths(module.filename);
|
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,
|
// 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
|
// and it can be overridden by custom print functions, such as `probe` or
|
||||||
// `eyes.js`.
|
// `eyes.js`.
|
||||||
@ -1263,7 +1256,7 @@ function complete(line, callback) {
|
|||||||
group.sort();
|
group.sort();
|
||||||
for (var j = group.length - 1; j >= 0; j--) {
|
for (var j = group.length - 1; j >= 0; j--) {
|
||||||
c = group[j];
|
c = group[j];
|
||||||
if (!hasOwnProperty(uniq, c)) {
|
if (!ObjectPrototype.hasOwnProperty(uniq, c)) {
|
||||||
completions.unshift(c);
|
completions.unshift(c);
|
||||||
uniq[c] = true;
|
uniq[c] = true;
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const { Buffer } = require('buffer');
|
const { Buffer } = require('buffer');
|
||||||
const pipeline = require('internal/streams/pipeline');
|
const pipeline = require('internal/streams/pipeline');
|
||||||
const eos = require('internal/streams/end-of-stream');
|
const eos = require('internal/streams/end-of-stream');
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const { Buffer } = require('buffer');
|
const { Buffer } = require('buffer');
|
||||||
const {
|
const {
|
||||||
kIncompleteCharactersStart,
|
kIncompleteCharactersStart,
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object } = primordials;
|
||||||
|
|
||||||
const net = require('net');
|
const net = require('net');
|
||||||
const { TTY, isTTY } = internalBinding('tty_wrap');
|
const { TTY, isTTY } = internalBinding('tty_wrap');
|
||||||
const errors = require('internal/errors');
|
const errors = require('internal/errors');
|
||||||
|
@ -21,9 +21,10 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { Object, SafeSet } = primordials;
|
||||||
|
|
||||||
const { toASCII } = require('internal/idna');
|
const { toASCII } = require('internal/idna');
|
||||||
const { encodeStr, hexTable } = require('internal/querystring');
|
const { encodeStr, hexTable } = require('internal/querystring');
|
||||||
const { SafeSet } = primordials;
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
ERR_INVALID_ARG_TYPE
|
ERR_INVALID_ARG_TYPE
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { ObjectPrototype, Reflect } = primordials;
|
const { Object, ObjectPrototype, Reflect } = primordials;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
codes: {
|
codes: {
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const { ObjectPrototype } = primordials;
|
||||||
|
|
||||||
const { Buffer } = require('buffer');
|
const { Buffer } = require('buffer');
|
||||||
const { validateString } = require('internal/validators');
|
const { validateString } = require('internal/validators');
|
||||||
const {
|
const {
|
||||||
@ -22,7 +24,6 @@ const {
|
|||||||
} = internalBinding('serdes');
|
} = internalBinding('serdes');
|
||||||
const assert = require('internal/assert');
|
const assert = require('internal/assert');
|
||||||
const { copy } = internalBinding('buffer');
|
const { copy } = internalBinding('buffer');
|
||||||
const { objectToString } = require('internal/util');
|
|
||||||
const { FastBuffer } = require('internal/buffer');
|
const { FastBuffer } = require('internal/buffer');
|
||||||
const { toPathIfFileURL } = require('internal/url');
|
const { toPathIfFileURL } = require('internal/url');
|
||||||
const { validatePath } = require('internal/fs/utils');
|
const { validatePath } = require('internal/fs/utils');
|
||||||
@ -193,7 +194,7 @@ const arrayBufferViewTypeToIndex = new Map();
|
|||||||
{
|
{
|
||||||
const dummy = new ArrayBuffer();
|
const dummy = new ArrayBuffer();
|
||||||
for (const [i, ctor] of arrayBufferViewTypes.entries()) {
|
for (const [i, ctor] of arrayBufferViewTypes.entries()) {
|
||||||
const tag = objectToString(new ctor(dummy));
|
const tag = ObjectPrototype.toString(new ctor(dummy));
|
||||||
arrayBufferViewTypeToIndex.set(tag, i);
|
arrayBufferViewTypeToIndex.set(tag, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -212,7 +213,7 @@ class DefaultSerializer extends Serializer {
|
|||||||
if (abView.constructor === Buffer) {
|
if (abView.constructor === Buffer) {
|
||||||
i = bufferConstructorIndex;
|
i = bufferConstructorIndex;
|
||||||
} else {
|
} else {
|
||||||
const tag = objectToString(abView);
|
const tag = ObjectPrototype.toString(abView);
|
||||||
i = arrayBufferViewTypeToIndex.get(tag);
|
i = arrayBufferViewTypeToIndex.get(tag);
|
||||||
|
|
||||||
if (i === undefined) {
|
if (i === undefined) {
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { Math } = primordials;
|
const { Math, Object } = primordials;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
codes: {
|
codes: {
|
||||||
|
@ -381,12 +381,14 @@ MaybeLocal<Value> StartExecution(Environment* env, const char* main_script_id) {
|
|||||||
env->process_string(),
|
env->process_string(),
|
||||||
env->require_string(),
|
env->require_string(),
|
||||||
env->internal_binding_string(),
|
env->internal_binding_string(),
|
||||||
|
env->primordials_string(),
|
||||||
FIXED_ONE_BYTE_STRING(env->isolate(), "markBootstrapComplete")};
|
FIXED_ONE_BYTE_STRING(env->isolate(), "markBootstrapComplete")};
|
||||||
|
|
||||||
std::vector<Local<Value>> arguments = {
|
std::vector<Local<Value>> arguments = {
|
||||||
env->process_object(),
|
env->process_object(),
|
||||||
env->native_module_require(),
|
env->native_module_require(),
|
||||||
env->internal_binding_loader(),
|
env->internal_binding_loader(),
|
||||||
|
env->primordials(),
|
||||||
env->NewFunctionTemplate(MarkBootstrapComplete)
|
env->NewFunctionTemplate(MarkBootstrapComplete)
|
||||||
->GetFunction(env->context())
|
->GetFunction(env->context())
|
||||||
.ToLocalChecked()};
|
.ToLocalChecked()};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user