tools: add prefer-proto
rule
fixup: add support for `Object.create(null)` fixup: extend to any 1-argument Object.create call fixup: add tests PR-URL: https://github.com/nodejs/node/pull/46083 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
parent
5d9a9a6ba3
commit
757c104147
@ -314,6 +314,7 @@ module.exports = {
|
|||||||
// Custom rules from eslint-plugin-node-core
|
// Custom rules from eslint-plugin-node-core
|
||||||
'node-core/no-unescaped-regexp-dot': 'error',
|
'node-core/no-unescaped-regexp-dot': 'error',
|
||||||
'node-core/no-duplicate-requires': 'error',
|
'node-core/no-duplicate-requires': 'error',
|
||||||
|
'node-core/prefer-proto': 'error',
|
||||||
},
|
},
|
||||||
globals: {
|
globals: {
|
||||||
ByteLengthQueuingStrategy: 'readable',
|
ByteLengthQueuingStrategy: 'readable',
|
||||||
|
@ -25,7 +25,7 @@ function runObject(n) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function runNullProtoObject(n) {
|
function runNullProtoObject(n) {
|
||||||
const m = Object.create(null);
|
const m = { __proto__: null };
|
||||||
bench.start();
|
bench.start();
|
||||||
for (let i = 0; i < n; i++) {
|
for (let i = 0; i < n; i++) {
|
||||||
m[`i${i}`] = i;
|
m[`i${i}`] = i;
|
||||||
@ -51,7 +51,7 @@ function runNullProtoLiteralObject(n) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function StorageObject() {}
|
function StorageObject() {}
|
||||||
StorageObject.prototype = Object.create(null);
|
StorageObject.prototype = { __proto__: null };
|
||||||
|
|
||||||
function runStorageObject(n) {
|
function runStorageObject(n) {
|
||||||
const m = new StorageObject();
|
const m = new StorageObject();
|
||||||
|
@ -664,7 +664,7 @@ const obj3 = {
|
|||||||
b: 1,
|
b: 1,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const obj4 = Object.create(obj1);
|
const obj4 = { __proto__: obj1 };
|
||||||
|
|
||||||
assert.deepEqual(obj1, obj1);
|
assert.deepEqual(obj1, obj1);
|
||||||
// OK
|
// OK
|
||||||
@ -699,7 +699,7 @@ const obj3 = {
|
|||||||
b: 1,
|
b: 1,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const obj4 = Object.create(obj1);
|
const obj4 = { __proto__: obj1 };
|
||||||
|
|
||||||
assert.deepEqual(obj1, obj1);
|
assert.deepEqual(obj1, obj1);
|
||||||
// OK
|
// OK
|
||||||
@ -1623,7 +1623,7 @@ const obj3 = {
|
|||||||
b: 1,
|
b: 1,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const obj4 = Object.create(obj1);
|
const obj4 = { __proto__: obj1 };
|
||||||
|
|
||||||
assert.notDeepEqual(obj1, obj1);
|
assert.notDeepEqual(obj1, obj1);
|
||||||
// AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } }
|
// AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } }
|
||||||
@ -1656,7 +1656,7 @@ const obj3 = {
|
|||||||
b: 1,
|
b: 1,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const obj4 = Object.create(obj1);
|
const obj4 = { __proto__: obj1 };
|
||||||
|
|
||||||
assert.notDeepEqual(obj1, obj1);
|
assert.notDeepEqual(obj1, obj1);
|
||||||
// AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } }
|
// AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } }
|
||||||
|
@ -32,7 +32,6 @@ const {
|
|||||||
FunctionPrototypeCall,
|
FunctionPrototypeCall,
|
||||||
NumberIsNaN,
|
NumberIsNaN,
|
||||||
NumberParseInt,
|
NumberParseInt,
|
||||||
ObjectCreate,
|
|
||||||
ObjectKeys,
|
ObjectKeys,
|
||||||
ObjectSetPrototypeOf,
|
ObjectSetPrototypeOf,
|
||||||
ObjectValues,
|
ObjectValues,
|
||||||
@ -111,9 +110,9 @@ function Agent(options) {
|
|||||||
|
|
||||||
// Don't confuse net and make it think that we're connecting to a pipe
|
// Don't confuse net and make it think that we're connecting to a pipe
|
||||||
this.options.path = null;
|
this.options.path = null;
|
||||||
this.requests = ObjectCreate(null);
|
this.requests = { __proto__: null };
|
||||||
this.sockets = ObjectCreate(null);
|
this.sockets = { __proto__: null };
|
||||||
this.freeSockets = ObjectCreate(null);
|
this.freeSockets = { __proto__: null };
|
||||||
this.keepAliveMsecs = this.options.keepAliveMsecs || 1000;
|
this.keepAliveMsecs = this.options.keepAliveMsecs || 1000;
|
||||||
this.keepAlive = this.options.keepAlive || false;
|
this.keepAlive = this.options.keepAlive || false;
|
||||||
this.maxSockets = this.options.maxSockets || Agent.defaultMaxSockets;
|
this.maxSockets = this.options.maxSockets || Agent.defaultMaxSockets;
|
||||||
|
@ -28,7 +28,6 @@ const {
|
|||||||
MathAbs,
|
MathAbs,
|
||||||
MathFloor,
|
MathFloor,
|
||||||
NumberPrototypeToString,
|
NumberPrototypeToString,
|
||||||
ObjectCreate,
|
|
||||||
ObjectDefineProperty,
|
ObjectDefineProperty,
|
||||||
ObjectKeys,
|
ObjectKeys,
|
||||||
ObjectValues,
|
ObjectValues,
|
||||||
@ -217,7 +216,7 @@ ObjectDefineProperty(OutgoingMessage.prototype, '_headers', {
|
|||||||
if (val == null) {
|
if (val == null) {
|
||||||
this[kOutHeaders] = null;
|
this[kOutHeaders] = null;
|
||||||
} else if (typeof val === 'object') {
|
} else if (typeof val === 'object') {
|
||||||
const headers = this[kOutHeaders] = ObjectCreate(null);
|
const headers = this[kOutHeaders] = { __proto__: null };
|
||||||
const keys = ObjectKeys(val);
|
const keys = ObjectKeys(val);
|
||||||
// Retain for(;;) loop for performance reasons
|
// Retain for(;;) loop for performance reasons
|
||||||
// Refs: https://github.com/nodejs/node/pull/30958
|
// Refs: https://github.com/nodejs/node/pull/30958
|
||||||
@ -244,7 +243,7 @@ ObjectDefineProperty(OutgoingMessage.prototype, '_headerNames', {
|
|||||||
get: internalUtil.deprecate(function() {
|
get: internalUtil.deprecate(function() {
|
||||||
const headers = this[kOutHeaders];
|
const headers = this[kOutHeaders];
|
||||||
if (headers !== null) {
|
if (headers !== null) {
|
||||||
const out = ObjectCreate(null);
|
const out = { __proto__: null };
|
||||||
const keys = ObjectKeys(headers);
|
const keys = ObjectKeys(headers);
|
||||||
// Retain for(;;) loop for performance reasons
|
// Retain for(;;) loop for performance reasons
|
||||||
// Refs: https://github.com/nodejs/node/pull/30958
|
// Refs: https://github.com/nodejs/node/pull/30958
|
||||||
@ -667,7 +666,7 @@ OutgoingMessage.prototype.setHeader = function setHeader(name, value) {
|
|||||||
|
|
||||||
let headers = this[kOutHeaders];
|
let headers = this[kOutHeaders];
|
||||||
if (headers === null)
|
if (headers === null)
|
||||||
this[kOutHeaders] = headers = ObjectCreate(null);
|
this[kOutHeaders] = headers = { __proto__: null };
|
||||||
|
|
||||||
headers[StringPrototypeToLowerCase(name)] = [name, value];
|
headers[StringPrototypeToLowerCase(name)] = [name, value];
|
||||||
return this;
|
return this;
|
||||||
@ -764,7 +763,7 @@ OutgoingMessage.prototype.getRawHeaderNames = function getRawHeaderNames() {
|
|||||||
// Returns a shallow copy of the current outgoing headers.
|
// Returns a shallow copy of the current outgoing headers.
|
||||||
OutgoingMessage.prototype.getHeaders = function getHeaders() {
|
OutgoingMessage.prototype.getHeaders = function getHeaders() {
|
||||||
const headers = this[kOutHeaders];
|
const headers = this[kOutHeaders];
|
||||||
const ret = ObjectCreate(null);
|
const ret = { __proto__: null };
|
||||||
if (headers) {
|
if (headers) {
|
||||||
const keys = ObjectKeys(headers);
|
const keys = ObjectKeys(headers);
|
||||||
// Retain for(;;) loop for performance reasons
|
// Retain for(;;) loop for performance reasons
|
||||||
|
@ -26,7 +26,6 @@ const tls = require('tls');
|
|||||||
const {
|
const {
|
||||||
ArrayPrototypePush,
|
ArrayPrototypePush,
|
||||||
JSONParse,
|
JSONParse,
|
||||||
ObjectCreate,
|
|
||||||
RegExpPrototypeSymbolReplace,
|
RegExpPrototypeSymbolReplace,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
@ -131,7 +130,7 @@ function translatePeerCertificate(c) {
|
|||||||
}
|
}
|
||||||
if (c.infoAccess != null) {
|
if (c.infoAccess != null) {
|
||||||
const info = c.infoAccess;
|
const info = c.infoAccess;
|
||||||
c.infoAccess = ObjectCreate(null);
|
c.infoAccess = { __proto__: null };
|
||||||
|
|
||||||
// XXX: More key validation?
|
// XXX: More key validation?
|
||||||
RegExpPrototypeSymbolReplace(/([^\n:]*):([^\n]*)(?:\n|$)/g, info,
|
RegExpPrototypeSymbolReplace(/([^\n:]*):([^\n]*)(?:\n|$)/g, info,
|
||||||
|
@ -33,7 +33,6 @@ const {
|
|||||||
NumberIsNaN,
|
NumberIsNaN,
|
||||||
NumberMAX_SAFE_INTEGER,
|
NumberMAX_SAFE_INTEGER,
|
||||||
NumberMIN_SAFE_INTEGER,
|
NumberMIN_SAFE_INTEGER,
|
||||||
ObjectCreate,
|
|
||||||
ObjectDefineProperties,
|
ObjectDefineProperties,
|
||||||
ObjectDefineProperty,
|
ObjectDefineProperty,
|
||||||
ObjectSetPrototypeOf,
|
ObjectSetPrototypeOf,
|
||||||
@ -146,7 +145,7 @@ const constants = ObjectDefineProperties({}, {
|
|||||||
Buffer.poolSize = 8 * 1024;
|
Buffer.poolSize = 8 * 1024;
|
||||||
let poolSize, poolOffset, allocPool;
|
let poolSize, poolOffset, allocPool;
|
||||||
|
|
||||||
const encodingsMap = ObjectCreate(null);
|
const encodingsMap = { __proto__: null };
|
||||||
for (let i = 0; i < encodings.length; ++i)
|
for (let i = 0; i < encodings.length; ++i)
|
||||||
encodingsMap[encodings[i]] = i;
|
encodingsMap[encodings[i]] = i;
|
||||||
|
|
||||||
@ -845,7 +844,7 @@ Buffer.prototype[customInspectSymbol] = function inspect(recurseTimes, ctx) {
|
|||||||
if (ctx) {
|
if (ctx) {
|
||||||
let extras = false;
|
let extras = false;
|
||||||
const filter = ctx.showHidden ? ALL_PROPERTIES : ONLY_ENUMERABLE;
|
const filter = ctx.showHidden ? ALL_PROPERTIES : ONLY_ENUMERABLE;
|
||||||
const obj = ObjectCreate(null);
|
const obj = { __proto__: null };
|
||||||
ArrayPrototypeForEach(getOwnNonIndexProperties(this, filter),
|
ArrayPrototypeForEach(getOwnNonIndexProperties(this, filter),
|
||||||
(key) => {
|
(key) => {
|
||||||
extras = true;
|
extras = true;
|
||||||
|
@ -4,7 +4,6 @@ const {
|
|||||||
ArrayPrototypeIndexOf,
|
ArrayPrototypeIndexOf,
|
||||||
ArrayPrototypePush,
|
ArrayPrototypePush,
|
||||||
ArrayPrototypeSplice,
|
ArrayPrototypeSplice,
|
||||||
ObjectCreate,
|
|
||||||
ObjectGetPrototypeOf,
|
ObjectGetPrototypeOf,
|
||||||
ObjectSetPrototypeOf,
|
ObjectSetPrototypeOf,
|
||||||
SymbolHasInstance,
|
SymbolHasInstance,
|
||||||
@ -92,7 +91,7 @@ class Channel {
|
|||||||
publish() {}
|
publish() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
const channels = ObjectCreate(null);
|
const channels = { __proto__: null };
|
||||||
|
|
||||||
function channel(name) {
|
function channel(name) {
|
||||||
let channel;
|
let channel;
|
||||||
|
@ -35,7 +35,6 @@ const {
|
|||||||
FunctionPrototypeCall,
|
FunctionPrototypeCall,
|
||||||
NumberIsNaN,
|
NumberIsNaN,
|
||||||
NumberMAX_SAFE_INTEGER,
|
NumberMAX_SAFE_INTEGER,
|
||||||
ObjectCreate,
|
|
||||||
ObjectDefineProperty,
|
ObjectDefineProperty,
|
||||||
ObjectDefineProperties,
|
ObjectDefineProperties,
|
||||||
ObjectGetPrototypeOf,
|
ObjectGetPrototypeOf,
|
||||||
@ -344,7 +343,7 @@ EventEmitter.init = function(opts) {
|
|||||||
|
|
||||||
if (this._events === undefined ||
|
if (this._events === undefined ||
|
||||||
this._events === ObjectGetPrototypeOf(this)._events) {
|
this._events === ObjectGetPrototypeOf(this)._events) {
|
||||||
this._events = ObjectCreate(null);
|
this._events = { __proto__: null };
|
||||||
this._eventsCount = 0;
|
this._eventsCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -553,7 +552,7 @@ function _addListener(target, type, listener, prepend) {
|
|||||||
|
|
||||||
events = target._events;
|
events = target._events;
|
||||||
if (events === undefined) {
|
if (events === undefined) {
|
||||||
events = target._events = ObjectCreate(null);
|
events = target._events = { __proto__: null };
|
||||||
target._eventsCount = 0;
|
target._eventsCount = 0;
|
||||||
} else {
|
} else {
|
||||||
// To avoid recursion in the case that type === "newListener"! Before
|
// To avoid recursion in the case that type === "newListener"! Before
|
||||||
@ -691,7 +690,7 @@ EventEmitter.prototype.removeListener =
|
|||||||
|
|
||||||
if (list === listener || list.listener === listener) {
|
if (list === listener || list.listener === listener) {
|
||||||
if (--this._eventsCount === 0)
|
if (--this._eventsCount === 0)
|
||||||
this._events = ObjectCreate(null);
|
this._events = { __proto__: null };
|
||||||
else {
|
else {
|
||||||
delete events[type];
|
delete events[type];
|
||||||
if (events.removeListener)
|
if (events.removeListener)
|
||||||
@ -746,11 +745,11 @@ EventEmitter.prototype.removeAllListeners =
|
|||||||
// Not listening for removeListener, no need to emit
|
// Not listening for removeListener, no need to emit
|
||||||
if (events.removeListener === undefined) {
|
if (events.removeListener === undefined) {
|
||||||
if (arguments.length === 0) {
|
if (arguments.length === 0) {
|
||||||
this._events = ObjectCreate(null);
|
this._events = { __proto__: null };
|
||||||
this._eventsCount = 0;
|
this._eventsCount = 0;
|
||||||
} else if (events[type] !== undefined) {
|
} else if (events[type] !== undefined) {
|
||||||
if (--this._eventsCount === 0)
|
if (--this._eventsCount === 0)
|
||||||
this._events = ObjectCreate(null);
|
this._events = { __proto__: null };
|
||||||
else
|
else
|
||||||
delete events[type];
|
delete events[type];
|
||||||
}
|
}
|
||||||
@ -764,7 +763,7 @@ EventEmitter.prototype.removeAllListeners =
|
|||||||
this.removeAllListeners(key);
|
this.removeAllListeners(key);
|
||||||
}
|
}
|
||||||
this.removeAllListeners('removeListener');
|
this.removeAllListeners('removeListener');
|
||||||
this._events = ObjectCreate(null);
|
this._events = { __proto__: null };
|
||||||
this._eventsCount = 0;
|
this._eventsCount = 0;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ const {
|
|||||||
Error,
|
Error,
|
||||||
ErrorCaptureStackTrace,
|
ErrorCaptureStackTrace,
|
||||||
MathMax,
|
MathMax,
|
||||||
ObjectCreate,
|
|
||||||
ObjectDefineProperty,
|
ObjectDefineProperty,
|
||||||
ObjectGetPrototypeOf,
|
ObjectGetPrototypeOf,
|
||||||
ObjectKeys,
|
ObjectKeys,
|
||||||
@ -48,7 +47,7 @@ const kMaxShortLength = 12;
|
|||||||
|
|
||||||
function copyError(source) {
|
function copyError(source) {
|
||||||
const keys = ObjectKeys(source);
|
const keys = ObjectKeys(source);
|
||||||
const target = ObjectCreate(ObjectGetPrototypeOf(source));
|
const target = { __proto__: ObjectGetPrototypeOf(source) };
|
||||||
for (const key of keys) {
|
for (const key of keys) {
|
||||||
target[key] = source[key];
|
target[key] = source[key];
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,6 @@ const {
|
|||||||
ArrayPrototypePush,
|
ArrayPrototypePush,
|
||||||
ArrayPrototypeSlice,
|
ArrayPrototypeSlice,
|
||||||
Error,
|
Error,
|
||||||
ObjectCreate,
|
|
||||||
ObjectDefineProperty,
|
ObjectDefineProperty,
|
||||||
ObjectKeys,
|
ObjectKeys,
|
||||||
ObjectPrototypeHasOwnProperty,
|
ObjectPrototypeHasOwnProperty,
|
||||||
@ -129,7 +128,7 @@ const schemelessBlockList = new SafeSet([
|
|||||||
|
|
||||||
// Set up process.binding() and process._linkedBinding().
|
// Set up process.binding() and process._linkedBinding().
|
||||||
{
|
{
|
||||||
const bindingObj = ObjectCreate(null);
|
const bindingObj = { __proto__: null };
|
||||||
|
|
||||||
process.binding = function binding(module) {
|
process.binding = function binding(module) {
|
||||||
module = String(module);
|
module = String(module);
|
||||||
@ -167,7 +166,7 @@ const schemelessBlockList = new SafeSet([
|
|||||||
*/
|
*/
|
||||||
let internalBinding;
|
let internalBinding;
|
||||||
{
|
{
|
||||||
const bindingObj = ObjectCreate(null);
|
const bindingObj = { __proto__: null };
|
||||||
// eslint-disable-next-line no-global-assign
|
// eslint-disable-next-line no-global-assign
|
||||||
internalBinding = function internalBinding(module) {
|
internalBinding = function internalBinding(module) {
|
||||||
let mod = bindingObj[module];
|
let mod = bindingObj[module];
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
const {
|
const {
|
||||||
ArrayIsArray,
|
ArrayIsArray,
|
||||||
Boolean,
|
Boolean,
|
||||||
ObjectCreate,
|
|
||||||
SafeMap,
|
SafeMap,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
@ -19,7 +18,7 @@ function RoundRobinHandle(key, address, { port, fd, flags, backlog, readableAll,
|
|||||||
this.key = key;
|
this.key = key;
|
||||||
this.all = new SafeMap();
|
this.all = new SafeMap();
|
||||||
this.free = new SafeMap();
|
this.free = new SafeMap();
|
||||||
this.handles = init(ObjectCreate(null));
|
this.handles = init({ __proto__: null });
|
||||||
this.handle = null;
|
this.handle = null;
|
||||||
this.server = net.createServer(assert.fail);
|
this.server = net.createServer(assert.fail);
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@ const {
|
|||||||
MathFloor,
|
MathFloor,
|
||||||
Number,
|
Number,
|
||||||
NumberPrototypeToFixed,
|
NumberPrototypeToFixed,
|
||||||
ObjectCreate,
|
|
||||||
ObjectDefineProperties,
|
ObjectDefineProperties,
|
||||||
ObjectDefineProperty,
|
ObjectDefineProperty,
|
||||||
ObjectKeys,
|
ObjectKeys,
|
||||||
@ -572,7 +571,7 @@ const consoleMethods = {
|
|||||||
return final([iterKey, valuesKey], [getIndexArray(length), values]);
|
return final([iterKey, valuesKey], [getIndexArray(length), values]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const map = ObjectCreate(null);
|
const map = { __proto__: null };
|
||||||
let hasPrimitives = false;
|
let hasPrimitives = false;
|
||||||
const valuesKeyArray = [];
|
const valuesKeyArray = [];
|
||||||
const indexKeyArray = ObjectKeys(tabularData);
|
const indexKeyArray = ObjectKeys(tabularData);
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
FunctionPrototypeBind,
|
FunctionPrototypeBind,
|
||||||
ObjectCreate,
|
|
||||||
ReflectDefineProperty,
|
ReflectDefineProperty,
|
||||||
ReflectGetOwnPropertyDescriptor,
|
ReflectGetOwnPropertyDescriptor,
|
||||||
ReflectOwnKeys,
|
ReflectOwnKeys,
|
||||||
@ -24,7 +23,7 @@ const {
|
|||||||
Console
|
Console
|
||||||
} = require('internal/console/constructor');
|
} = require('internal/console/constructor');
|
||||||
|
|
||||||
const globalConsole = ObjectCreate({});
|
const globalConsole = { __proto__: {} };
|
||||||
|
|
||||||
// Since Console is not on the prototype chain of the global console,
|
// Since Console is not on the prototype chain of the global console,
|
||||||
// the symbol properties on Console.prototype have to be looked up from
|
// the symbol properties on Console.prototype have to be looked up from
|
||||||
|
@ -9,7 +9,6 @@ const {
|
|||||||
NumberParseInt,
|
NumberParseInt,
|
||||||
RegExpPrototypeExec,
|
RegExpPrototypeExec,
|
||||||
RegExpPrototypeSymbolReplace,
|
RegExpPrototypeSymbolReplace,
|
||||||
ObjectCreate,
|
|
||||||
Symbol,
|
Symbol,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
@ -286,7 +285,7 @@ function setDefaultResultOrder(value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function createResolverClass(resolver) {
|
function createResolverClass(resolver) {
|
||||||
const resolveMap = ObjectCreate(null);
|
const resolveMap = { __proto__: null };
|
||||||
|
|
||||||
class Resolver extends ResolverBase {}
|
class Resolver extends ResolverBase {}
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
Boolean,
|
Boolean,
|
||||||
ObjectCreate,
|
|
||||||
ObjectDefineProperties,
|
ObjectDefineProperties,
|
||||||
ObjectGetOwnPropertyDescriptors,
|
ObjectGetOwnPropertyDescriptors,
|
||||||
ObjectSetPrototypeOf,
|
ObjectSetPrototypeOf,
|
||||||
@ -350,9 +349,9 @@ class TextEncoder {
|
|||||||
if (typeof depth === 'number' && depth < 0)
|
if (typeof depth === 'number' && depth < 0)
|
||||||
return this;
|
return this;
|
||||||
const ctor = getConstructorOf(this);
|
const ctor = getConstructorOf(this);
|
||||||
const obj = ObjectCreate({
|
const obj = { __proto__: {
|
||||||
constructor: ctor === null ? TextEncoder : ctor
|
constructor: ctor === null ? TextEncoder : ctor
|
||||||
});
|
} };
|
||||||
obj.encoding = this.encoding;
|
obj.encoding = this.encoding;
|
||||||
// Lazy to avoid circular dependency
|
// Lazy to avoid circular dependency
|
||||||
return require('internal/util/inspect').inspect(obj, opts);
|
return require('internal/util/inspect').inspect(obj, opts);
|
||||||
@ -571,7 +570,7 @@ const sharedProperties = ObjectGetOwnPropertyDescriptors({
|
|||||||
if (typeof depth === 'number' && depth < 0)
|
if (typeof depth === 'number' && depth < 0)
|
||||||
return this;
|
return this;
|
||||||
const constructor = getConstructorOf(this) || TextDecoder;
|
const constructor = getConstructorOf(this) || TextDecoder;
|
||||||
const obj = ObjectCreate({ constructor });
|
const obj = { __proto__: { constructor } };
|
||||||
obj.encoding = this.encoding;
|
obj.encoding = this.encoding;
|
||||||
obj.fatal = this.fatal;
|
obj.fatal = this.fatal;
|
||||||
obj.ignoreBOM = this.ignoreBOM;
|
obj.ignoreBOM = this.ignoreBOM;
|
||||||
|
@ -33,7 +33,7 @@ const errors = {
|
|||||||
const errorConstructorNames = new SafeSet(ObjectKeys(errors));
|
const errorConstructorNames = new SafeSet(ObjectKeys(errors));
|
||||||
|
|
||||||
function TryGetAllProperties(object, target = object) {
|
function TryGetAllProperties(object, target = object) {
|
||||||
const all = ObjectCreate(null);
|
const all = { __proto__: null };
|
||||||
if (object === null)
|
if (object === null)
|
||||||
return all;
|
return all;
|
||||||
ObjectAssign(all,
|
ObjectAssign(all,
|
||||||
|
@ -6,7 +6,6 @@ const {
|
|||||||
Boolean,
|
Boolean,
|
||||||
FunctionPrototypeBind,
|
FunctionPrototypeBind,
|
||||||
ObjectAssign,
|
ObjectAssign,
|
||||||
ObjectCreate,
|
|
||||||
ObjectKeys,
|
ObjectKeys,
|
||||||
ObjectPrototypeHasOwnProperty,
|
ObjectPrototypeHasOwnProperty,
|
||||||
Proxy,
|
Proxy,
|
||||||
@ -483,8 +482,8 @@ class Http2ServerResponse extends Stream {
|
|||||||
sendDate: true,
|
sendDate: true,
|
||||||
statusCode: HTTP_STATUS_OK,
|
statusCode: HTTP_STATUS_OK,
|
||||||
};
|
};
|
||||||
this[kHeaders] = ObjectCreate(null);
|
this[kHeaders] = { __proto__: null };
|
||||||
this[kTrailers] = ObjectCreate(null);
|
this[kTrailers] = { __proto__: null };
|
||||||
this[kStream] = stream;
|
this[kStream] = stream;
|
||||||
stream[kProxySocket] = null;
|
stream[kProxySocket] = null;
|
||||||
stream[kResponse] = this;
|
stream[kResponse] = this;
|
||||||
@ -603,7 +602,7 @@ class Http2ServerResponse extends Stream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getHeaders() {
|
getHeaders() {
|
||||||
const headers = ObjectCreate(null);
|
const headers = { __proto__: null };
|
||||||
return ObjectAssign(headers, this[kHeaders]);
|
return ObjectAssign(headers, this[kHeaders]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -851,7 +850,7 @@ class Http2ServerResponse extends Stream {
|
|||||||
writeEarlyHints(hints) {
|
writeEarlyHints(hints) {
|
||||||
validateObject(hints, 'hints');
|
validateObject(hints, 'hints');
|
||||||
|
|
||||||
const headers = ObjectCreate(null);
|
const headers = { __proto__: null };
|
||||||
|
|
||||||
const linkHeaderValue = validateLinkHeaderValue(hints.link);
|
const linkHeaderValue = validateLinkHeaderValue(hints.link);
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@ const {
|
|||||||
FunctionPrototypeCall,
|
FunctionPrototypeCall,
|
||||||
MathMin,
|
MathMin,
|
||||||
ObjectAssign,
|
ObjectAssign,
|
||||||
ObjectCreate,
|
|
||||||
ObjectKeys,
|
ObjectKeys,
|
||||||
ObjectDefineProperty,
|
ObjectDefineProperty,
|
||||||
ObjectPrototypeHasOwnProperty,
|
ObjectPrototypeHasOwnProperty,
|
||||||
@ -1753,7 +1752,7 @@ class ClientHttp2Session extends Http2Session {
|
|||||||
assertIsObject(headers, 'headers');
|
assertIsObject(headers, 'headers');
|
||||||
assertIsObject(options, 'options');
|
assertIsObject(options, 'options');
|
||||||
|
|
||||||
headers = ObjectAssign(ObjectCreate(null), headers);
|
headers = ObjectAssign({ __proto__: null }, headers);
|
||||||
options = { ...options };
|
options = { ...options };
|
||||||
|
|
||||||
if (headers[HTTP2_HEADER_METHOD] === undefined)
|
if (headers[HTTP2_HEADER_METHOD] === undefined)
|
||||||
@ -2252,7 +2251,7 @@ class Http2Stream extends Duplex {
|
|||||||
throw new ERR_HTTP2_TRAILERS_NOT_READY();
|
throw new ERR_HTTP2_TRAILERS_NOT_READY();
|
||||||
|
|
||||||
assertIsObject(headers, 'headers');
|
assertIsObject(headers, 'headers');
|
||||||
headers = ObjectAssign(ObjectCreate(null), headers);
|
headers = ObjectAssign({ __proto__: null }, headers);
|
||||||
|
|
||||||
debugStreamObj(this, 'sending trailers');
|
debugStreamObj(this, 'sending trailers');
|
||||||
|
|
||||||
@ -2420,7 +2419,7 @@ function callStreamClose(stream) {
|
|||||||
|
|
||||||
function processHeaders(oldHeaders, options) {
|
function processHeaders(oldHeaders, options) {
|
||||||
assertIsObject(oldHeaders, 'headers');
|
assertIsObject(oldHeaders, 'headers');
|
||||||
const headers = ObjectCreate(null);
|
const headers = { __proto__: null };
|
||||||
|
|
||||||
if (oldHeaders !== null && oldHeaders !== undefined) {
|
if (oldHeaders !== null && oldHeaders !== undefined) {
|
||||||
// This loop is here for performance reason. Do not change.
|
// This loop is here for performance reason. Do not change.
|
||||||
@ -2696,7 +2695,7 @@ class ServerHttp2Stream extends Http2Stream {
|
|||||||
options.endStream = !!options.endStream;
|
options.endStream = !!options.endStream;
|
||||||
|
|
||||||
assertIsObject(headers, 'headers');
|
assertIsObject(headers, 'headers');
|
||||||
headers = ObjectAssign(ObjectCreate(null), headers);
|
headers = ObjectAssign({ __proto__: null }, headers);
|
||||||
|
|
||||||
if (headers[HTTP2_HEADER_METHOD] === undefined)
|
if (headers[HTTP2_HEADER_METHOD] === undefined)
|
||||||
headers[HTTP2_HEADER_METHOD] = HTTP2_METHOD_GET;
|
headers[HTTP2_HEADER_METHOD] = HTTP2_METHOD_GET;
|
||||||
@ -2931,7 +2930,7 @@ class ServerHttp2Stream extends Http2Stream {
|
|||||||
throw new ERR_HTTP2_HEADERS_AFTER_RESPOND();
|
throw new ERR_HTTP2_HEADERS_AFTER_RESPOND();
|
||||||
|
|
||||||
assertIsObject(headers, 'headers');
|
assertIsObject(headers, 'headers');
|
||||||
headers = ObjectAssign(ObjectCreate(null), headers);
|
headers = ObjectAssign({ __proto__: null }, headers);
|
||||||
|
|
||||||
debugStreamObj(this, 'sending additional headers');
|
debugStreamObj(this, 'sending additional headers');
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ const {
|
|||||||
Error,
|
Error,
|
||||||
MathMax,
|
MathMax,
|
||||||
Number,
|
Number,
|
||||||
ObjectCreate,
|
|
||||||
ObjectDefineProperty,
|
ObjectDefineProperty,
|
||||||
ObjectKeys,
|
ObjectKeys,
|
||||||
SafeSet,
|
SafeSet,
|
||||||
@ -279,7 +278,7 @@ function updateOptionsBuffer(options) {
|
|||||||
function getDefaultSettings() {
|
function getDefaultSettings() {
|
||||||
settingsBuffer[IDX_SETTINGS_FLAGS] = 0;
|
settingsBuffer[IDX_SETTINGS_FLAGS] = 0;
|
||||||
binding.refreshDefaultSettings();
|
binding.refreshDefaultSettings();
|
||||||
const holder = ObjectCreate(null);
|
const holder = { __proto__: null };
|
||||||
|
|
||||||
const flags = settingsBuffer[IDX_SETTINGS_FLAGS];
|
const flags = settingsBuffer[IDX_SETTINGS_FLAGS];
|
||||||
|
|
||||||
@ -588,7 +587,7 @@ const assertWithinRange = hideStackFrames(
|
|||||||
);
|
);
|
||||||
|
|
||||||
function toHeaderObject(headers, sensitiveHeaders) {
|
function toHeaderObject(headers, sensitiveHeaders) {
|
||||||
const obj = ObjectCreate(null);
|
const obj = { __proto__: null };
|
||||||
for (let n = 0; n < headers.length; n += 2) {
|
for (let n = 0; n < headers.length; n += 2) {
|
||||||
const name = headers[n];
|
const name = headers[n];
|
||||||
let value = headers[n + 1];
|
let value = headers[n + 1];
|
||||||
|
@ -38,7 +38,6 @@ const {
|
|||||||
Boolean,
|
Boolean,
|
||||||
Error,
|
Error,
|
||||||
JSONParse,
|
JSONParse,
|
||||||
ObjectCreate,
|
|
||||||
ObjectDefineProperty,
|
ObjectDefineProperty,
|
||||||
ObjectFreeze,
|
ObjectFreeze,
|
||||||
ObjectGetOwnPropertyDescriptor,
|
ObjectGetOwnPropertyDescriptor,
|
||||||
@ -146,7 +145,7 @@ const {
|
|||||||
const { kEvaluated } = internalBinding('module_wrap');
|
const { kEvaluated } = internalBinding('module_wrap');
|
||||||
const isWindows = process.platform === 'win32';
|
const isWindows = process.platform === 'win32';
|
||||||
|
|
||||||
const relativeResolveCache = ObjectCreate(null);
|
const relativeResolveCache = { __proto__: null };
|
||||||
|
|
||||||
let requireDepth = 0;
|
let requireDepth = 0;
|
||||||
let statCache = null;
|
let statCache = null;
|
||||||
@ -208,9 +207,9 @@ function Module(id = '', parent) {
|
|||||||
this.children = [];
|
this.children = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
Module._cache = ObjectCreate(null);
|
Module._cache = { __proto__: null };
|
||||||
Module._pathCache = ObjectCreate(null);
|
Module._pathCache = { __proto__: null };
|
||||||
Module._extensions = ObjectCreate(null);
|
Module._extensions = { __proto__: null };
|
||||||
let modulePaths = [];
|
let modulePaths = [];
|
||||||
Module.globalPaths = [];
|
Module.globalPaths = [];
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
const {
|
const {
|
||||||
ArrayPrototypeFilter,
|
ArrayPrototypeFilter,
|
||||||
ArrayPrototypeIncludes,
|
ArrayPrototypeIncludes,
|
||||||
ObjectCreate,
|
|
||||||
ObjectValues,
|
ObjectValues,
|
||||||
ObjectPrototypeHasOwnProperty,
|
ObjectPrototypeHasOwnProperty,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
@ -53,7 +52,7 @@ const supportedAssertionTypes = ArrayPrototypeFilter(
|
|||||||
* @throws {TypeError} If the format and assertion type are incompatible.
|
* @throws {TypeError} If the format and assertion type are incompatible.
|
||||||
*/
|
*/
|
||||||
function validateAssertions(url, format,
|
function validateAssertions(url, format,
|
||||||
importAssertions = ObjectCreate(null)) {
|
importAssertions = { __proto__: null }) {
|
||||||
const validType = formatTypeMap[format];
|
const validType = formatTypeMap[format];
|
||||||
|
|
||||||
switch (validType) {
|
switch (validType) {
|
||||||
|
@ -4,7 +4,6 @@ const {
|
|||||||
ArrayPrototypeJoin,
|
ArrayPrototypeJoin,
|
||||||
ArrayPrototypeMap,
|
ArrayPrototypeMap,
|
||||||
JSONStringify,
|
JSONStringify,
|
||||||
ObjectCreate,
|
|
||||||
SafeSet,
|
SafeSet,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
@ -40,12 +39,12 @@ import.meta.done();
|
|||||||
|
|
||||||
const readyfns = new SafeSet();
|
const readyfns = new SafeSet();
|
||||||
const reflect = {
|
const reflect = {
|
||||||
exports: ObjectCreate(null),
|
exports: { __proto__: null },
|
||||||
onReady: (cb) => { readyfns.add(cb); },
|
onReady: (cb) => { readyfns.add(cb); },
|
||||||
};
|
};
|
||||||
|
|
||||||
if (imports.length)
|
if (imports.length)
|
||||||
reflect.imports = ObjectCreate(null);
|
reflect.imports = { __proto__: null };
|
||||||
const { setCallbackForWrap } = require('internal/modules/esm/utils');
|
const { setCallbackForWrap } = require('internal/modules/esm/utils');
|
||||||
setCallbackForWrap(m, {
|
setCallbackForWrap(m, {
|
||||||
initializeImportMeta: (meta, wrap) => {
|
initializeImportMeta: (meta, wrap) => {
|
||||||
|
@ -7,7 +7,6 @@ const {
|
|||||||
Array,
|
Array,
|
||||||
ArrayIsArray,
|
ArrayIsArray,
|
||||||
FunctionPrototypeCall,
|
FunctionPrototypeCall,
|
||||||
ObjectCreate,
|
|
||||||
ObjectSetPrototypeOf,
|
ObjectSetPrototypeOf,
|
||||||
SafePromiseAllReturnArrayLike,
|
SafePromiseAllReturnArrayLike,
|
||||||
SafeWeakMap,
|
SafeWeakMap,
|
||||||
@ -303,7 +302,7 @@ class ESMLoader {
|
|||||||
async resolve(
|
async resolve(
|
||||||
originalSpecifier,
|
originalSpecifier,
|
||||||
parentURL,
|
parentURL,
|
||||||
importAssertions = ObjectCreate(null),
|
importAssertions = { __proto__: null },
|
||||||
) {
|
) {
|
||||||
if (this.#hooks) {
|
if (this.#hooks) {
|
||||||
return this.#hooks.resolve(originalSpecifier, parentURL, importAssertions);
|
return this.#hooks.resolve(originalSpecifier, parentURL, importAssertions);
|
||||||
|
@ -5,7 +5,6 @@ const {
|
|||||||
ArrayPrototypePush,
|
ArrayPrototypePush,
|
||||||
ArrayPrototypeSome,
|
ArrayPrototypeSome,
|
||||||
FunctionPrototype,
|
FunctionPrototype,
|
||||||
ObjectCreate,
|
|
||||||
ObjectSetPrototypeOf,
|
ObjectSetPrototypeOf,
|
||||||
PromiseResolve,
|
PromiseResolve,
|
||||||
PromisePrototypeThen,
|
PromisePrototypeThen,
|
||||||
@ -51,7 +50,7 @@ const isCommonJSGlobalLikeNotDefinedError = (errorMessage) =>
|
|||||||
class ModuleJob {
|
class ModuleJob {
|
||||||
// `loader` is the Loader instance used for loading dependencies.
|
// `loader` is the Loader instance used for loading dependencies.
|
||||||
// `moduleProvider` is a function
|
// `moduleProvider` is a function
|
||||||
constructor(loader, url, importAssertions = ObjectCreate(null),
|
constructor(loader, url, importAssertions = { __proto__: null },
|
||||||
moduleProvider, isMain, inspectBrk) {
|
moduleProvider, isMain, inspectBrk) {
|
||||||
this.loader = loader;
|
this.loader = loader;
|
||||||
this.importAssertions = importAssertions;
|
this.importAssertions = importAssertions;
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
const { kImplicitAssertType } = require('internal/modules/esm/assert');
|
const { kImplicitAssertType } = require('internal/modules/esm/assert');
|
||||||
const {
|
const {
|
||||||
ObjectCreate,
|
|
||||||
SafeMap,
|
SafeMap,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
let debug = require('internal/util/debuglog').debuglog('esm', (fn) => {
|
let debug = require('internal/util/debuglog').debuglog('esm', (fn) => {
|
||||||
@ -31,7 +30,7 @@ class ModuleMap extends SafeMap {
|
|||||||
debug(`Storing ${url} (${
|
debug(`Storing ${url} (${
|
||||||
type === kImplicitAssertType ? 'implicit type' : type
|
type === kImplicitAssertType ? 'implicit type' : type
|
||||||
}) in ModuleMap`);
|
}) in ModuleMap`);
|
||||||
const cachedJobsForUrl = super.get(url) ?? ObjectCreate(null);
|
const cachedJobsForUrl = super.get(url) ?? { __proto__: null };
|
||||||
cachedJobsForUrl[type] = job;
|
cachedJobsForUrl[type] = job;
|
||||||
return super.set(url, cachedJobsForUrl);
|
return super.set(url, cachedJobsForUrl);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const {
|
const {
|
||||||
ObjectCreate,
|
|
||||||
StringPrototypeEndsWith,
|
StringPrototypeEndsWith,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
@ -54,7 +53,7 @@ function runMainESM(mainPath) {
|
|||||||
handleMainPromise(loadESM((esmLoader) => {
|
handleMainPromise(loadESM((esmLoader) => {
|
||||||
const main = path.isAbsolute(mainPath) ?
|
const main = path.isAbsolute(mainPath) ?
|
||||||
pathToFileURL(mainPath).href : mainPath;
|
pathToFileURL(mainPath).href : mainPath;
|
||||||
return esmLoader.import(main, undefined, ObjectCreate(null));
|
return esmLoader.import(main, undefined, { __proto__: null });
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
const {
|
const {
|
||||||
ArrayIsArray,
|
ArrayIsArray,
|
||||||
ArrayPrototypeSort,
|
ArrayPrototypeSort,
|
||||||
ObjectCreate,
|
|
||||||
ObjectEntries,
|
ObjectEntries,
|
||||||
ObjectFreeze,
|
ObjectFreeze,
|
||||||
ObjectKeys,
|
ObjectKeys,
|
||||||
@ -178,7 +177,7 @@ class DependencyMapperInstance {
|
|||||||
/**
|
/**
|
||||||
* @type {Record<string, string>}
|
* @type {Record<string, string>}
|
||||||
*/
|
*/
|
||||||
const normalizedDependencyMap = ObjectCreate(null);
|
const normalizedDependencyMap = { __proto__: null };
|
||||||
for (let specifier in dependencies) {
|
for (let specifier in dependencies) {
|
||||||
const target = dependencies[specifier];
|
const target = dependencies[specifier];
|
||||||
specifier = canonicalizeSpecifier(specifier, manifest.href);
|
specifier = canonicalizeSpecifier(specifier, manifest.href);
|
||||||
@ -443,10 +442,10 @@ class Manifest {
|
|||||||
|
|
||||||
this.#reaction = reaction;
|
this.#reaction = reaction;
|
||||||
const jsonResourcesEntries = ObjectEntries(
|
const jsonResourcesEntries = ObjectEntries(
|
||||||
obj.resources ?? ObjectCreate(null)
|
obj.resources ?? { __proto__: null }
|
||||||
);
|
);
|
||||||
const jsonScopesEntries = ObjectEntries(obj.scopes ?? ObjectCreate(null));
|
const jsonScopesEntries = ObjectEntries(obj.scopes ?? { __proto__: null });
|
||||||
const defaultDependencies = obj.dependencies ?? ObjectCreate(null);
|
const defaultDependencies = obj.dependencies ?? { __proto__: null };
|
||||||
|
|
||||||
this.#defaultDependencies = new DependencyMapperInstance(
|
this.#defaultDependencies = new DependencyMapperInstance(
|
||||||
'default',
|
'default',
|
||||||
|
@ -4,13 +4,12 @@ const {
|
|||||||
Number,
|
Number,
|
||||||
NumberIsNaN,
|
NumberIsNaN,
|
||||||
NumberParseInt,
|
NumberParseInt,
|
||||||
ObjectCreate,
|
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
const REPL = require('repl');
|
const REPL = require('repl');
|
||||||
const { kStandaloneREPL } = require('internal/repl/utils');
|
const { kStandaloneREPL } = require('internal/repl/utils');
|
||||||
|
|
||||||
module.exports = ObjectCreate(REPL);
|
module.exports = { __proto__: REPL };
|
||||||
module.exports.createInternalRepl = createRepl;
|
module.exports.createInternalRepl = createRepl;
|
||||||
|
|
||||||
function createRepl(env, opts, cb) {
|
function createRepl(env, opts, cb) {
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
const {
|
const {
|
||||||
ArrayPrototypeMap,
|
ArrayPrototypeMap,
|
||||||
JSONParse,
|
JSONParse,
|
||||||
ObjectCreate,
|
|
||||||
ObjectKeys,
|
ObjectKeys,
|
||||||
ObjectGetOwnPropertyDescriptor,
|
ObjectGetOwnPropertyDescriptor,
|
||||||
ObjectPrototypeHasOwnProperty,
|
ObjectPrototypeHasOwnProperty,
|
||||||
@ -280,7 +279,7 @@ function sourcesToAbsolute(baseURL, data) {
|
|||||||
// Get serialized representation of source-map cache, this is used
|
// Get serialized representation of source-map cache, this is used
|
||||||
// to persist a cache of source-maps to disk when NODE_V8_COVERAGE is enabled.
|
// to persist a cache of source-maps to disk when NODE_V8_COVERAGE is enabled.
|
||||||
function sourceMapCacheToObject() {
|
function sourceMapCacheToObject() {
|
||||||
const obj = ObjectCreate(null);
|
const obj = { __proto__: null };
|
||||||
|
|
||||||
for (const { 0: k, 1: v } of esmSourceMapCache) {
|
for (const { 0: k, 1: v } of esmSourceMapCache) {
|
||||||
obj[k] = v;
|
obj[k] = v;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const {
|
const {
|
||||||
ArrayPrototypePush,
|
ArrayPrototypePush,
|
||||||
ObjectCreate,
|
|
||||||
ObjectGetOwnPropertyDescriptor,
|
ObjectGetOwnPropertyDescriptor,
|
||||||
SafePromiseAllReturnArrayLike,
|
SafePromiseAllReturnArrayLike,
|
||||||
RegExp,
|
RegExp,
|
||||||
@ -128,7 +127,7 @@ async function getReportersMap(reporters, destinations) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { esmLoader } = require('internal/process/esm_loader');
|
const { esmLoader } = require('internal/process/esm_loader');
|
||||||
reporter = await esmLoader.import(name, parentURL, ObjectCreate(null));
|
reporter = await esmLoader.import(name, parentURL, { __proto__: null });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reporter?.default) {
|
if (reporter?.default) {
|
||||||
|
@ -77,7 +77,6 @@ const {
|
|||||||
MathTrunc,
|
MathTrunc,
|
||||||
NumberIsFinite,
|
NumberIsFinite,
|
||||||
NumberMIN_SAFE_INTEGER,
|
NumberMIN_SAFE_INTEGER,
|
||||||
ObjectCreate,
|
|
||||||
ReflectApply,
|
ReflectApply,
|
||||||
Symbol,
|
Symbol,
|
||||||
} = primordials;
|
} = primordials;
|
||||||
@ -154,7 +153,7 @@ const timerListQueue = new PriorityQueue(compareTimersLists, setPosition);
|
|||||||
//
|
//
|
||||||
// - key = time in milliseconds
|
// - key = time in milliseconds
|
||||||
// - value = linked list
|
// - value = linked list
|
||||||
const timerListMap = ObjectCreate(null);
|
const timerListMap = { __proto__: null };
|
||||||
|
|
||||||
function initAsyncResource(resource, type) {
|
function initAsyncResource(resource, type) {
|
||||||
const asyncId = resource[async_id_symbol] = newAsyncId();
|
const asyncId = resource[async_id_symbol] = newAsyncId();
|
||||||
|
@ -10,7 +10,6 @@ const {
|
|||||||
FunctionPrototypeBind,
|
FunctionPrototypeBind,
|
||||||
Int8Array,
|
Int8Array,
|
||||||
Number,
|
Number,
|
||||||
ObjectCreate,
|
|
||||||
ObjectDefineProperties,
|
ObjectDefineProperties,
|
||||||
ObjectDefineProperty,
|
ObjectDefineProperty,
|
||||||
ObjectGetOwnPropertySymbols,
|
ObjectGetOwnPropertySymbols,
|
||||||
@ -673,7 +672,7 @@ class URL {
|
|||||||
return this;
|
return this;
|
||||||
|
|
||||||
const constructor = getConstructorOf(this) || URL;
|
const constructor = getConstructorOf(this) || URL;
|
||||||
const obj = ObjectCreate({ constructor });
|
const obj = { __proto__: { constructor } };
|
||||||
|
|
||||||
obj.href = this.href;
|
obj.href = this.href;
|
||||||
obj.origin = this.origin;
|
obj.origin = this.origin;
|
||||||
@ -1295,7 +1294,7 @@ function merge(out, start, mid, end, lBuffer, rBuffer) {
|
|||||||
|
|
||||||
// https://heycam.github.io/webidl/#dfn-default-iterator-object
|
// https://heycam.github.io/webidl/#dfn-default-iterator-object
|
||||||
function createSearchParamsIterator(target, kind) {
|
function createSearchParamsIterator(target, kind) {
|
||||||
const iterator = ObjectCreate(URLSearchParamsIteratorPrototype);
|
const iterator = { __proto__: URLSearchParamsIteratorPrototype };
|
||||||
iterator[context] = {
|
iterator[context] = {
|
||||||
target,
|
target,
|
||||||
kind,
|
kind,
|
||||||
@ -1305,7 +1304,7 @@ function createSearchParamsIterator(target, kind) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// https://heycam.github.io/webidl/#dfn-iterator-prototype-object
|
// https://heycam.github.io/webidl/#dfn-iterator-prototype-object
|
||||||
const URLSearchParamsIteratorPrototype = ObjectCreate(IteratorPrototype);
|
const URLSearchParamsIteratorPrototype = { __proto__: IteratorPrototype };
|
||||||
|
|
||||||
defineIDLClass(URLSearchParamsIteratorPrototype, 'URLSearchParams Iterator', {
|
defineIDLClass(URLSearchParamsIteratorPrototype, 'URLSearchParams Iterator', {
|
||||||
next() {
|
next() {
|
||||||
@ -1585,7 +1584,7 @@ function constructUrl(flags, protocol, username, password,
|
|||||||
ctx.fragment = fragment;
|
ctx.fragment = fragment;
|
||||||
ctx.host = host;
|
ctx.host = host;
|
||||||
|
|
||||||
const url = ObjectCreate(URL.prototype);
|
const url = { __proto__: URL.prototype };
|
||||||
url[context] = ctx;
|
url[context] = ctx;
|
||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
url[searchParams] = params;
|
url[searchParams] = params;
|
||||||
|
@ -9,7 +9,6 @@ const {
|
|||||||
ArrayPrototypeSort,
|
ArrayPrototypeSort,
|
||||||
Error,
|
Error,
|
||||||
FunctionPrototypeCall,
|
FunctionPrototypeCall,
|
||||||
ObjectCreate,
|
|
||||||
ObjectDefineProperties,
|
ObjectDefineProperties,
|
||||||
ObjectDefineProperty,
|
ObjectDefineProperty,
|
||||||
ObjectGetOwnPropertyDescriptor,
|
ObjectGetOwnPropertyDescriptor,
|
||||||
@ -289,7 +288,7 @@ function getSignalsToNamesMapping() {
|
|||||||
if (signalsToNamesMapping !== undefined)
|
if (signalsToNamesMapping !== undefined)
|
||||||
return signalsToNamesMapping;
|
return signalsToNamesMapping;
|
||||||
|
|
||||||
signalsToNamesMapping = ObjectCreate(null);
|
signalsToNamesMapping = { __proto__: null };
|
||||||
for (const key in signals) {
|
for (const key in signals) {
|
||||||
signalsToNamesMapping[signals[key]] = key;
|
signalsToNamesMapping[signals[key]] = key;
|
||||||
}
|
}
|
||||||
@ -610,14 +609,14 @@ const lazyDOMException = hideStackFrames((message, name) => {
|
|||||||
return new _DOMException(message, name);
|
return new _DOMException(message, name);
|
||||||
});
|
});
|
||||||
|
|
||||||
const kEnumerableProperty = ObjectCreate(null);
|
const kEnumerableProperty = { __proto__: null };
|
||||||
kEnumerableProperty.enumerable = true;
|
kEnumerableProperty.enumerable = true;
|
||||||
ObjectFreeze(kEnumerableProperty);
|
ObjectFreeze(kEnumerableProperty);
|
||||||
|
|
||||||
const kEmptyObject = ObjectFreeze(ObjectCreate(null));
|
const kEmptyObject = ObjectFreeze({ __proto__: null });
|
||||||
|
|
||||||
function filterOwnProperties(source, keys) {
|
function filterOwnProperties(source, keys) {
|
||||||
const filtered = ObjectCreate(null);
|
const filtered = { __proto__: null };
|
||||||
for (let i = 0; i < keys.length; i++) {
|
for (let i = 0; i < keys.length; i++) {
|
||||||
const key = keys[i];
|
const key = keys[i];
|
||||||
if (ObjectPrototypeHasOwnProperty(source, key)) {
|
if (ObjectPrototypeHasOwnProperty(source, key)) {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const {
|
const {
|
||||||
ObjectCreate,
|
|
||||||
ObjectDefineProperty,
|
ObjectDefineProperty,
|
||||||
RegExp,
|
RegExp,
|
||||||
RegExpPrototypeExec,
|
RegExpPrototypeExec,
|
||||||
@ -20,7 +19,7 @@ let testEnabled;
|
|||||||
|
|
||||||
// `debugEnv` is initial value of process.env.NODE_DEBUG
|
// `debugEnv` is initial value of process.env.NODE_DEBUG
|
||||||
function initializeDebugEnv(debugEnv) {
|
function initializeDebugEnv(debugEnv) {
|
||||||
debugImpls = ObjectCreate(null);
|
debugImpls = { __proto__: null };
|
||||||
if (debugEnv) {
|
if (debugEnv) {
|
||||||
// This is run before any user code, it's OK not to use primordials.
|
// This is run before any user code, it's OK not to use primordials.
|
||||||
debugEnv = debugEnv.replace(/[|\\{}()[\]^$+?.]/g, '\\$&')
|
debugEnv = debugEnv.replace(/[|\\{}()[\]^$+?.]/g, '\\$&')
|
||||||
|
@ -43,7 +43,6 @@ const {
|
|||||||
NumberPrototypeValueOf,
|
NumberPrototypeValueOf,
|
||||||
Object,
|
Object,
|
||||||
ObjectAssign,
|
ObjectAssign,
|
||||||
ObjectCreate,
|
|
||||||
ObjectDefineProperty,
|
ObjectDefineProperty,
|
||||||
ObjectGetOwnPropertyDescriptor,
|
ObjectGetOwnPropertyDescriptor,
|
||||||
ObjectGetOwnPropertyNames,
|
ObjectGetOwnPropertyNames,
|
||||||
@ -460,7 +459,7 @@ defineColorAlias('doubleunderline', 'doubleUnderline');
|
|||||||
|
|
||||||
// TODO(BridgeAR): Add function style support for more complex styles.
|
// TODO(BridgeAR): Add function style support for more complex styles.
|
||||||
// Don't use 'blue' not visible on cmd.exe
|
// Don't use 'blue' not visible on cmd.exe
|
||||||
inspect.styles = ObjectAssign(ObjectCreate(null), {
|
inspect.styles = ObjectAssign({ __proto__: null }, {
|
||||||
special: 'cyan',
|
special: 'cyan',
|
||||||
number: 'yellow',
|
number: 'yellow',
|
||||||
bigint: 'yellow',
|
bigint: 'yellow',
|
||||||
|
@ -6,7 +6,6 @@ const {
|
|||||||
ArrayPrototypeForEach,
|
ArrayPrototypeForEach,
|
||||||
ArrayPrototypeIndexOf,
|
ArrayPrototypeIndexOf,
|
||||||
ArrayPrototypeSome,
|
ArrayPrototypeSome,
|
||||||
ObjectCreate,
|
|
||||||
ObjectDefineProperty,
|
ObjectDefineProperty,
|
||||||
ObjectGetPrototypeOf,
|
ObjectGetPrototypeOf,
|
||||||
ObjectSetPrototypeOf,
|
ObjectSetPrototypeOf,
|
||||||
@ -234,7 +233,7 @@ class Module {
|
|||||||
return this;
|
return this;
|
||||||
|
|
||||||
const constructor = getConstructorOf(this) || Module;
|
const constructor = getConstructorOf(this) || Module;
|
||||||
const o = ObjectCreate({ constructor });
|
const o = { __proto__: { constructor } };
|
||||||
o.status = this.status;
|
o.status = this.status;
|
||||||
o.identifier = this.identifier;
|
o.identifier = this.identifier;
|
||||||
o.context = this.context;
|
o.context = this.context;
|
||||||
|
@ -8,7 +8,6 @@ const {
|
|||||||
FunctionPrototypeCall,
|
FunctionPrototypeCall,
|
||||||
MathMax,
|
MathMax,
|
||||||
NumberIsNaN,
|
NumberIsNaN,
|
||||||
ObjectCreate,
|
|
||||||
PromisePrototypeThen,
|
PromisePrototypeThen,
|
||||||
PromiseResolve,
|
PromiseResolve,
|
||||||
PromiseReject,
|
PromiseReject,
|
||||||
@ -54,20 +53,11 @@ const {
|
|||||||
const kState = Symbol('kState');
|
const kState = Symbol('kState');
|
||||||
const kType = Symbol('kType');
|
const kType = Symbol('kType');
|
||||||
|
|
||||||
const AsyncIterator = ObjectCreate(AsyncIteratorPrototype, {
|
const AsyncIterator = {
|
||||||
next: {
|
__proto__: AsyncIteratorPrototype,
|
||||||
__proto__: null,
|
next: undefined,
|
||||||
configurable: true,
|
return: undefined,
|
||||||
enumerable: true,
|
};
|
||||||
writable: true,
|
|
||||||
},
|
|
||||||
return: {
|
|
||||||
__proto__: null,
|
|
||||||
configurable: true,
|
|
||||||
enumerable: true,
|
|
||||||
writable: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
function extractHighWaterMark(value, defaultHWM) {
|
function extractHighWaterMark(value, defaultHWM) {
|
||||||
if (value === undefined) return defaultHWM;
|
if (value === undefined) return defaultHWM;
|
||||||
|
@ -8,7 +8,6 @@ const {
|
|||||||
FunctionPrototypeBind,
|
FunctionPrototypeBind,
|
||||||
JSONStringify,
|
JSONStringify,
|
||||||
MathMax,
|
MathMax,
|
||||||
ObjectCreate,
|
|
||||||
ObjectEntries,
|
ObjectEntries,
|
||||||
Promise,
|
Promise,
|
||||||
PromiseResolve,
|
PromiseResolve,
|
||||||
@ -173,7 +172,7 @@ class Worker extends EventEmitter {
|
|||||||
|
|
||||||
let env;
|
let env;
|
||||||
if (typeof options.env === 'object' && options.env !== null) {
|
if (typeof options.env === 'object' && options.env !== null) {
|
||||||
env = ObjectCreate(null);
|
env = { __proto__: null };
|
||||||
ArrayPrototypeForEach(
|
ArrayPrototypeForEach(
|
||||||
ObjectEntries(options.env),
|
ObjectEntries(options.env),
|
||||||
({ 0: key, 1: value }) => { env[key] = `${value}`; }
|
({ 0: key, 1: value }) => { env[key] = `${value}`; }
|
||||||
|
@ -278,7 +278,7 @@ ObjectDefineProperty(MessagePort.prototype, inspect.custom, {
|
|||||||
// e.g. when accessing the prototype directly.
|
// e.g. when accessing the prototype directly.
|
||||||
ref = FunctionPrototypeCall(MessagePortPrototype.hasRef, this);
|
ref = FunctionPrototypeCall(MessagePortPrototype.hasRef, this);
|
||||||
} catch { return this; }
|
} catch { return this; }
|
||||||
return ObjectAssign(ObjectCreate(MessagePort.prototype),
|
return ObjectAssign({ __proto__: MessagePort.prototype },
|
||||||
ref === undefined ? {
|
ref === undefined ? {
|
||||||
active: false,
|
active: false,
|
||||||
} : {
|
} : {
|
||||||
|
@ -34,7 +34,6 @@ const {
|
|||||||
ObjectDefineProperty,
|
ObjectDefineProperty,
|
||||||
ObjectSetPrototypeOf,
|
ObjectSetPrototypeOf,
|
||||||
Symbol,
|
Symbol,
|
||||||
ObjectCreate,
|
|
||||||
} = primordials;
|
} = primordials;
|
||||||
|
|
||||||
const EventEmitter = require('events');
|
const EventEmitter = require('events');
|
||||||
@ -1977,16 +1976,16 @@ function onconnection(err, clientHandle) {
|
|||||||
|
|
||||||
if (self.maxConnections && self._connections >= self.maxConnections) {
|
if (self.maxConnections && self._connections >= self.maxConnections) {
|
||||||
if (clientHandle.getsockname || clientHandle.getpeername) {
|
if (clientHandle.getsockname || clientHandle.getpeername) {
|
||||||
const data = ObjectCreate(null);
|
const data = { __proto__: null };
|
||||||
if (clientHandle.getsockname) {
|
if (clientHandle.getsockname) {
|
||||||
const localInfo = ObjectCreate(null);
|
const localInfo = { __proto__: null };
|
||||||
clientHandle.getsockname(localInfo);
|
clientHandle.getsockname(localInfo);
|
||||||
data.localAddress = localInfo.address;
|
data.localAddress = localInfo.address;
|
||||||
data.localPort = localInfo.port;
|
data.localPort = localInfo.port;
|
||||||
data.localFamily = localInfo.family;
|
data.localFamily = localInfo.family;
|
||||||
}
|
}
|
||||||
if (clientHandle.getpeername) {
|
if (clientHandle.getpeername) {
|
||||||
const remoteInfo = ObjectCreate(null);
|
const remoteInfo = { __proto__: null };
|
||||||
clientHandle.getpeername(remoteInfo);
|
clientHandle.getpeername(remoteInfo);
|
||||||
data.remoteAddress = remoteInfo.address;
|
data.remoteAddress = remoteInfo.address;
|
||||||
data.remotePort = remoteInfo.port;
|
data.remotePort = remoteInfo.port;
|
||||||
|
@ -29,7 +29,6 @@ const {
|
|||||||
Int8Array,
|
Int8Array,
|
||||||
MathAbs,
|
MathAbs,
|
||||||
NumberIsFinite,
|
NumberIsFinite,
|
||||||
ObjectCreate,
|
|
||||||
ObjectKeys,
|
ObjectKeys,
|
||||||
String,
|
String,
|
||||||
StringPrototypeCharCodeAt,
|
StringPrototypeCharCodeAt,
|
||||||
@ -316,7 +315,7 @@ function addKeyVal(obj, key, value, keyEncoded, valEncoded, decode) {
|
|||||||
* @returns {Record<string, string | string[]>}
|
* @returns {Record<string, string | string[]>}
|
||||||
*/
|
*/
|
||||||
function parse(qs, sep, eq, options) {
|
function parse(qs, sep, eq, options) {
|
||||||
const obj = ObjectCreate(null);
|
const obj = { __proto__: null };
|
||||||
|
|
||||||
if (typeof qs !== 'string' || qs.length === 0) {
|
if (typeof qs !== 'string' || qs.length === 0) {
|
||||||
return obj;
|
return obj;
|
||||||
|
@ -66,7 +66,6 @@ const {
|
|||||||
NumberIsNaN,
|
NumberIsNaN,
|
||||||
NumberParseFloat,
|
NumberParseFloat,
|
||||||
ObjectAssign,
|
ObjectAssign,
|
||||||
ObjectCreate,
|
|
||||||
ObjectDefineProperty,
|
ObjectDefineProperty,
|
||||||
ObjectGetOwnPropertyDescriptor,
|
ObjectGetOwnPropertyDescriptor,
|
||||||
ObjectGetOwnPropertyNames,
|
ObjectGetOwnPropertyNames,
|
||||||
@ -773,7 +772,7 @@ function REPLServer(prompt,
|
|||||||
|
|
||||||
self.resetContext();
|
self.resetContext();
|
||||||
|
|
||||||
this.commands = ObjectCreate(null);
|
this.commands = { __proto__: null };
|
||||||
defineDefaultCommands(this);
|
defineDefaultCommands(this);
|
||||||
|
|
||||||
// Figure out which "writer" function to use
|
// Figure out which "writer" function to use
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
MathTrunc,
|
MathTrunc,
|
||||||
ObjectCreate,
|
|
||||||
ObjectDefineProperty,
|
ObjectDefineProperty,
|
||||||
SymbolToPrimitive
|
SymbolToPrimitive
|
||||||
} = primordials;
|
} = primordials;
|
||||||
@ -72,7 +71,7 @@ const {
|
|||||||
// This stores all the known timer async ids to allow users to clearTimeout and
|
// This stores all the known timer async ids to allow users to clearTimeout and
|
||||||
// clearInterval using those ids, to match the spec and the rest of the web
|
// clearInterval using those ids, to match the spec and the rest of the web
|
||||||
// platform.
|
// platform.
|
||||||
const knownTimersById = ObjectCreate(null);
|
const knownTimersById = { __proto__: null };
|
||||||
|
|
||||||
// Remove a timer. Cancels the timeout and resets the relevant timer properties.
|
// Remove a timer. Cancels the timeout and resets the relevant timer properties.
|
||||||
function unenroll(item) {
|
function unenroll(item) {
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
|
|
||||||
const {
|
const {
|
||||||
Int8Array,
|
Int8Array,
|
||||||
ObjectCreate,
|
|
||||||
ObjectKeys,
|
ObjectKeys,
|
||||||
SafeSet,
|
SafeSet,
|
||||||
StringPrototypeCharCodeAt,
|
StringPrototypeCharCodeAt,
|
||||||
@ -267,7 +266,7 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) {
|
|||||||
}
|
}
|
||||||
} else if (parseQueryString) {
|
} else if (parseQueryString) {
|
||||||
this.search = null;
|
this.search = null;
|
||||||
this.query = ObjectCreate(null);
|
this.query = { __proto__: null };
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -477,7 +476,7 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) {
|
|||||||
} else if (parseQueryString) {
|
} else if (parseQueryString) {
|
||||||
// No query string, but parseQueryString still requested
|
// No query string, but parseQueryString still requested
|
||||||
this.search = null;
|
this.search = null;
|
||||||
this.query = ObjectCreate(null);
|
this.query = { __proto__: null };
|
||||||
}
|
}
|
||||||
|
|
||||||
const useQuestionIdx =
|
const useQuestionIdx =
|
||||||
|
@ -100,7 +100,7 @@ module.exports = function verifyGraph(hooks, graph) {
|
|||||||
assert.strictEqual(errors.length, 0);
|
assert.strictEqual(errors.length, 0);
|
||||||
|
|
||||||
// Verify that all expected types are present (but more/others are allowed)
|
// Verify that all expected types are present (but more/others are allowed)
|
||||||
const expTypes = Object.create(null);
|
const expTypes = { __proto__: null };
|
||||||
for (let i = 0; i < graph.length; i++) {
|
for (let i = 0; i < graph.length; i++) {
|
||||||
if (expTypes[graph[i].type] == null) expTypes[graph[i].type] = 0;
|
if (expTypes[graph[i].type] == null) expTypes[graph[i].type] = 0;
|
||||||
expTypes[graph[i].type]++;
|
expTypes[graph[i].type]++;
|
||||||
|
@ -235,9 +235,9 @@ assert.strictEqual(newObject.test_string, 'test string');
|
|||||||
// i.e.: includes prototypes, only enumerable properties, skips symbols,
|
// i.e.: includes prototypes, only enumerable properties, skips symbols,
|
||||||
// and includes indices and converts them to strings.
|
// and includes indices and converts them to strings.
|
||||||
|
|
||||||
const object = Object.create({
|
const object = { __proto__: {
|
||||||
inherited: 1
|
inherited: 1
|
||||||
});
|
} };
|
||||||
|
|
||||||
const fooSymbol = Symbol('foo');
|
const fooSymbol = Symbol('foo');
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ const { setTimeout: sleep } = require('timers/promises');
|
|||||||
NaN,
|
NaN,
|
||||||
true,
|
true,
|
||||||
'AbortController',
|
'AbortController',
|
||||||
Object.create(AbortController.prototype),
|
{ __proto__: AbortController.prototype },
|
||||||
];
|
];
|
||||||
for (const badController of badAbortControllers) {
|
for (const badController of badAbortControllers) {
|
||||||
throws(
|
throws(
|
||||||
@ -134,7 +134,7 @@ const { setTimeout: sleep } = require('timers/promises');
|
|||||||
NaN,
|
NaN,
|
||||||
true,
|
true,
|
||||||
'AbortSignal',
|
'AbortSignal',
|
||||||
Object.create(AbortSignal.prototype),
|
{ __proto__: AbortSignal.prototype },
|
||||||
];
|
];
|
||||||
for (const badSignal of badAbortSignals) {
|
for (const badSignal of badAbortSignals) {
|
||||||
throws(
|
throws(
|
||||||
|
@ -1190,7 +1190,7 @@ assert.throws(
|
|||||||
});
|
});
|
||||||
assertNotDeepOrStrict(a, b);
|
assertNotDeepOrStrict(a, b);
|
||||||
|
|
||||||
a = Object.create(null);
|
a = { __proto__: null };
|
||||||
b = new RangeError('abc');
|
b = new RangeError('abc');
|
||||||
Object.defineProperty(a, Symbol.toStringTag, {
|
Object.defineProperty(a, Symbol.toStringTag, {
|
||||||
value: 'Error'
|
value: 'Error'
|
||||||
|
@ -290,7 +290,7 @@ assert.throws(() => new Blob({}), {
|
|||||||
|
|
||||||
{
|
{
|
||||||
// Testing the defaults
|
// Testing the defaults
|
||||||
[undefined, null, Object.create(null), { type: undefined }, {
|
[undefined, null, { __proto__: null }, { type: undefined }, {
|
||||||
get type() {}, // eslint-disable-line getter-return
|
get type() {}, // eslint-disable-line getter-return
|
||||||
}].forEach((options) => {
|
}].forEach((options) => {
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
|
@ -40,7 +40,7 @@ deepStrictEqual(
|
|||||||
{ valueOf() { return null; } },
|
{ valueOf() { return null; } },
|
||||||
{ valueOf() { return undefined; } },
|
{ valueOf() { return undefined; } },
|
||||||
{ valueOf: null },
|
{ valueOf: null },
|
||||||
Object.create(null),
|
{ __proto__: null },
|
||||||
new Number(true),
|
new Number(true),
|
||||||
new MyBadPrimitive(),
|
new MyBadPrimitive(),
|
||||||
Symbol(),
|
Symbol(),
|
||||||
|
@ -192,7 +192,7 @@ function setPrototypeOfQuux(root) {
|
|||||||
// Test various supported types, directly and nested:
|
// Test various supported types, directly and nested:
|
||||||
[
|
[
|
||||||
undefined, null, false, true, 42, 42n, Symbol('42'), NaN, Infinity, {}, [],
|
undefined, null, false, true, 42, 42n, Symbol('42'), NaN, Infinity, {}, [],
|
||||||
() => {}, async () => {}, Promise.resolve(), Math, Object.create(null),
|
() => {}, async () => {}, Promise.resolve(), Math, { __proto__: null },
|
||||||
].forEach((target) => {
|
].forEach((target) => {
|
||||||
assert.deepStrictEqual(mustNotMutateObjectDeep(target), target);
|
assert.deepStrictEqual(mustNotMutateObjectDeep(target), target);
|
||||||
assert.deepStrictEqual(mustNotMutateObjectDeep({ target }), { target });
|
assert.deepStrictEqual(mustNotMutateObjectDeep({ target }), { target });
|
||||||
|
@ -211,7 +211,7 @@ const der = Buffer.from(
|
|||||||
|
|
||||||
// Verify that legacy encoding works
|
// Verify that legacy encoding works
|
||||||
const legacyObjectCheck = {
|
const legacyObjectCheck = {
|
||||||
subject: Object.assign(Object.create(null), {
|
subject: Object.assign({ __proto__: null }, {
|
||||||
C: 'US',
|
C: 'US',
|
||||||
ST: 'CA',
|
ST: 'CA',
|
||||||
L: 'SF',
|
L: 'SF',
|
||||||
@ -220,7 +220,7 @@ const der = Buffer.from(
|
|||||||
CN: 'agent1',
|
CN: 'agent1',
|
||||||
emailAddress: 'ry@tinyclouds.org',
|
emailAddress: 'ry@tinyclouds.org',
|
||||||
}),
|
}),
|
||||||
issuer: Object.assign(Object.create(null), {
|
issuer: Object.assign({ __proto__: null }, {
|
||||||
C: 'US',
|
C: 'US',
|
||||||
ST: 'CA',
|
ST: 'CA',
|
||||||
L: 'SF',
|
L: 'SF',
|
||||||
@ -229,7 +229,7 @@ const der = Buffer.from(
|
|||||||
CN: 'ca1',
|
CN: 'ca1',
|
||||||
emailAddress: 'ry@tinyclouds.org',
|
emailAddress: 'ry@tinyclouds.org',
|
||||||
}),
|
}),
|
||||||
infoAccess: Object.assign(Object.create(null), {
|
infoAccess: Object.assign({ __proto__: null }, {
|
||||||
'OCSP - URI': ['http://ocsp.nodejs.org/'],
|
'OCSP - URI': ['http://ocsp.nodejs.org/'],
|
||||||
'CA Issuers - URI': ['http://ca.nodejs.org/ca.cert']
|
'CA Issuers - URI': ['http://ca.nodejs.org/ca.cert']
|
||||||
}),
|
}),
|
||||||
|
@ -33,7 +33,7 @@ strictEqual(
|
|||||||
);
|
);
|
||||||
|
|
||||||
strictEqual(
|
strictEqual(
|
||||||
determineSpecificType(Object.create(null)),
|
determineSpecificType({ __proto__: null }),
|
||||||
'[Object: null prototype] {}',
|
'[Object: null prototype] {}',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
71
test/parallel/test-eslint-prefer-proto.js
Normal file
71
test/parallel/test-eslint-prefer-proto.js
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
if ((!common.hasCrypto) || (!common.hasIntl)) {
|
||||||
|
common.skip('ESLint tests require crypto and Intl');
|
||||||
|
}
|
||||||
|
|
||||||
|
common.skipIfEslintMissing();
|
||||||
|
|
||||||
|
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
|
||||||
|
const rule = require('../../tools/eslint-rules/prefer-proto');
|
||||||
|
|
||||||
|
new RuleTester({
|
||||||
|
parserOptions: { ecmaVersion: 2022 }
|
||||||
|
}).run('prefer-common-mustsucceed', rule, {
|
||||||
|
valid: [
|
||||||
|
'({ __proto__: null })',
|
||||||
|
'const x = { __proto__: null };',
|
||||||
|
`
|
||||||
|
class X {
|
||||||
|
field = { __proto__: null };
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.x = { __proto__: X };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
'foo({ __proto__: Array.prototype })',
|
||||||
|
'({ "__proto__": null })',
|
||||||
|
"({ '__proto__': null })",
|
||||||
|
'ObjectCreate(null, undefined)',
|
||||||
|
'Object.create(null, undefined)',
|
||||||
|
'Object.create(null, undefined, undefined)',
|
||||||
|
'ObjectCreate(null, descriptors)',
|
||||||
|
'Object.create(null, descriptors)',
|
||||||
|
'ObjectCreate(Foo.prototype, descriptors)',
|
||||||
|
'Object.create(Foo.prototype, descriptors)',
|
||||||
|
],
|
||||||
|
invalid: [
|
||||||
|
{
|
||||||
|
code: 'ObjectCreate(null)',
|
||||||
|
output: '{ __proto__: null }',
|
||||||
|
errors: [{ messageId: 'error', data: { value: 'null' } }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: 'Object.create(null)',
|
||||||
|
output: '{ __proto__: null }',
|
||||||
|
errors: [{ messageId: 'error', data: { value: 'null' } }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: 'ObjectCreate(null,)',
|
||||||
|
output: '{ __proto__: null }',
|
||||||
|
errors: [{ messageId: 'error', data: { value: 'null' } }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: 'Object.create(null,)',
|
||||||
|
output: '{ __proto__: null }',
|
||||||
|
errors: [{ messageId: 'error', data: { value: 'null' } }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: 'ObjectCreate(Foo)',
|
||||||
|
output: '{ __proto__: Foo }',
|
||||||
|
errors: [{ messageId: 'error', data: { value: 'Foo' } }],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: 'Object.create(Foo)',
|
||||||
|
output: '{ __proto__: Foo }',
|
||||||
|
errors: [{ messageId: 'error', data: { value: 'Foo' } }],
|
||||||
|
},
|
||||||
|
]
|
||||||
|
});
|
@ -8,7 +8,7 @@ const EE = new EventEmitter();
|
|||||||
|
|
||||||
// Works as expected if the context has no `constructor.name`
|
// Works as expected if the context has no `constructor.name`
|
||||||
{
|
{
|
||||||
const ctx = Object.create(null);
|
const ctx = { __proto__: null };
|
||||||
assert.throws(
|
assert.throws(
|
||||||
() => EE.emit.call(ctx, 'error', new Error('foo')),
|
() => EE.emit.call(ctx, 'error', new Error('foo')),
|
||||||
common.expectsError({ name: 'Error', message: 'foo' })
|
common.expectsError({ name: 'Error', message: 'foo' })
|
||||||
|
@ -50,7 +50,7 @@ const rangeFile = fixtures.path('x.txt');
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const file = fs.createReadStream(fn, Object.create({ encoding: 'utf8' }));
|
const file = fs.createReadStream(fn, { __proto__: { encoding: 'utf8' } });
|
||||||
file.length = 0;
|
file.length = 0;
|
||||||
file.on('data', function(data) {
|
file.on('data', function(data) {
|
||||||
assert.strictEqual(typeof data, 'string');
|
assert.strictEqual(typeof data, 'string');
|
||||||
@ -68,7 +68,7 @@ const rangeFile = fixtures.path('x.txt');
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const options = Object.create({ bufferSize: 1, start: 1, end: 2 });
|
const options = { __proto__: { bufferSize: 1, start: 1, end: 2 } };
|
||||||
const file = fs.createReadStream(rangeFile, options);
|
const file = fs.createReadStream(rangeFile, options);
|
||||||
assert.strictEqual(file.start, 1);
|
assert.strictEqual(file.start, 1);
|
||||||
assert.strictEqual(file.end, 2);
|
assert.strictEqual(file.end, 2);
|
||||||
@ -82,7 +82,7 @@ const rangeFile = fixtures.path('x.txt');
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const options = Object.create({ bufferSize: 1, start: 1 });
|
const options = { __proto__: { bufferSize: 1, start: 1 } };
|
||||||
const file = fs.createReadStream(rangeFile, options);
|
const file = fs.createReadStream(rangeFile, options);
|
||||||
assert.strictEqual(file.start, 1);
|
assert.strictEqual(file.start, 1);
|
||||||
file.data = '';
|
file.data = '';
|
||||||
@ -96,7 +96,7 @@ const rangeFile = fixtures.path('x.txt');
|
|||||||
|
|
||||||
// https://github.com/joyent/node/issues/2320
|
// https://github.com/joyent/node/issues/2320
|
||||||
{
|
{
|
||||||
const options = Object.create({ bufferSize: 1.23, start: 1 });
|
const options = { __proto__: { bufferSize: 1.23, start: 1 } };
|
||||||
const file = fs.createReadStream(rangeFile, options);
|
const file = fs.createReadStream(rangeFile, options);
|
||||||
assert.strictEqual(file.start, 1);
|
assert.strictEqual(file.start, 1);
|
||||||
file.data = '';
|
file.data = '';
|
||||||
@ -115,7 +115,7 @@ const rangeFile = fixtures.path('x.txt');
|
|||||||
|
|
||||||
assert.throws(
|
assert.throws(
|
||||||
() => {
|
() => {
|
||||||
fs.createReadStream(rangeFile, Object.create({ start: 10, end: 2 }));
|
fs.createReadStream(rangeFile, { __proto__: { start: 10, end: 2 } });
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
code: 'ERR_OUT_OF_RANGE',
|
code: 'ERR_OUT_OF_RANGE',
|
||||||
@ -125,7 +125,7 @@ const rangeFile = fixtures.path('x.txt');
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const options = Object.create({ start: 0, end: 0 });
|
const options = { __proto__: { start: 0, end: 0 } };
|
||||||
const stream = fs.createReadStream(rangeFile, options);
|
const stream = fs.createReadStream(rangeFile, options);
|
||||||
assert.strictEqual(stream.start, 0);
|
assert.strictEqual(stream.start, 0);
|
||||||
assert.strictEqual(stream.end, 0);
|
assert.strictEqual(stream.end, 0);
|
||||||
@ -150,7 +150,7 @@ const rangeFile = fixtures.path('x.txt');
|
|||||||
{
|
{
|
||||||
let data = '';
|
let data = '';
|
||||||
let file =
|
let file =
|
||||||
fs.createReadStream(rangeFile, Object.create({ autoClose: false }));
|
fs.createReadStream(rangeFile, { __proto__: { autoClose: false } });
|
||||||
assert.strictEqual(file.autoClose, false);
|
assert.strictEqual(file.autoClose, false);
|
||||||
file.on('data', (chunk) => { data += chunk; });
|
file.on('data', (chunk) => { data += chunk; });
|
||||||
file.on('end', common.mustCall(function() {
|
file.on('end', common.mustCall(function() {
|
||||||
@ -164,7 +164,7 @@ const rangeFile = fixtures.path('x.txt');
|
|||||||
|
|
||||||
function fileNext() {
|
function fileNext() {
|
||||||
// This will tell us if the fd is usable again or not.
|
// This will tell us if the fd is usable again or not.
|
||||||
file = fs.createReadStream(null, Object.create({ fd: file.fd, start: 0 }));
|
file = fs.createReadStream(null, { __proto__: { fd: file.fd, start: 0 } });
|
||||||
file.data = '';
|
file.data = '';
|
||||||
file.on('data', function(data) {
|
file.on('data', function(data) {
|
||||||
file.data += data;
|
file.data += data;
|
||||||
@ -181,7 +181,7 @@ const rangeFile = fixtures.path('x.txt');
|
|||||||
|
|
||||||
// Just to make sure autoClose won't close the stream because of error.
|
// Just to make sure autoClose won't close the stream because of error.
|
||||||
{
|
{
|
||||||
const options = Object.create({ fd: 13337, autoClose: false });
|
const options = { __proto__: { fd: 13337, autoClose: false } };
|
||||||
const file = fs.createReadStream(null, options);
|
const file = fs.createReadStream(null, options);
|
||||||
file.on('data', common.mustNotCall());
|
file.on('data', common.mustNotCall());
|
||||||
file.on('error', common.mustCall());
|
file.on('error', common.mustCall());
|
||||||
|
@ -81,7 +81,7 @@ const server = createServer(
|
|||||||
['X-Res-a', 'X-Res-b', 'Connection', 'x-res-c', 'x-res-d']
|
['X-Res-a', 'X-Res-b', 'Connection', 'x-res-c', 'x-res-d']
|
||||||
);
|
);
|
||||||
|
|
||||||
const headers = Object.create(null);
|
const headers = { __proto__: null };
|
||||||
Object.assign(headers, {
|
Object.assign(headers, {
|
||||||
'x-res-a': [ 'AAA', 'BBB', 'CCC' ],
|
'x-res-a': [ 'AAA', 'BBB', 'CCC' ],
|
||||||
'x-res-b': [ 'DDD', 'EEE', 'FFF', 'GGG' ],
|
'x-res-b': [ 'DDD', 'EEE', 'FFF', 'GGG' ],
|
||||||
|
@ -44,7 +44,7 @@ const s = http.createServer(common.mustCall((req, res) => {
|
|||||||
case 'headers': {
|
case 'headers': {
|
||||||
// Check that header-related functions work before setting any headers
|
// Check that header-related functions work before setting any headers
|
||||||
const headers = res.getHeaders();
|
const headers = res.getHeaders();
|
||||||
const exoticObj = Object.create(null);
|
const exoticObj = { __proto__: null };
|
||||||
assert.deepStrictEqual(headers, exoticObj);
|
assert.deepStrictEqual(headers, exoticObj);
|
||||||
assert.deepStrictEqual(res.getHeaderNames(), []);
|
assert.deepStrictEqual(res.getHeaderNames(), []);
|
||||||
assert.deepStrictEqual(res.getRawHeaderNames(), []);
|
assert.deepStrictEqual(res.getRawHeaderNames(), []);
|
||||||
|
@ -17,7 +17,7 @@ common.expectWarning('DeprecationWarning', warn, 'DEP0066');
|
|||||||
// Tests _headerNames getter result after setting a header.
|
// Tests _headerNames getter result after setting a header.
|
||||||
const outgoingMessage = new OutgoingMessage();
|
const outgoingMessage = new OutgoingMessage();
|
||||||
outgoingMessage.setHeader('key', 'value');
|
outgoingMessage.setHeader('key', 'value');
|
||||||
const expect = Object.create(null);
|
const expect = { __proto__: null };
|
||||||
expect.key = 'key';
|
expect.key = 'key';
|
||||||
assert.deepStrictEqual(outgoingMessage._headerNames, expect);
|
assert.deepStrictEqual(outgoingMessage._headerNames, expect);
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ server.listen(0, common.mustCall(function() {
|
|||||||
response.setHeader(real, expectedValue);
|
response.setHeader(real, expectedValue);
|
||||||
const expectedHeaderNames = [real];
|
const expectedHeaderNames = [real];
|
||||||
assert.deepStrictEqual(response.getHeaderNames(), expectedHeaderNames);
|
assert.deepStrictEqual(response.getHeaderNames(), expectedHeaderNames);
|
||||||
const expectedHeaders = Object.create(null);
|
const expectedHeaders = { __proto__: null };
|
||||||
expectedHeaders[real] = expectedValue;
|
expectedHeaders[real] = expectedValue;
|
||||||
assert.deepStrictEqual(response.getHeaders(), expectedHeaders);
|
assert.deepStrictEqual(response.getHeaders(), expectedHeaders);
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ const http2 = require('http2');
|
|||||||
|
|
||||||
const server = http2.createServer();
|
const server = http2.createServer();
|
||||||
|
|
||||||
const src = Object.create(null);
|
const src = { __proto__: null };
|
||||||
src['www-authenticate'] = 'foo';
|
src['www-authenticate'] = 'foo';
|
||||||
src['WWW-Authenticate'] = 'bar';
|
src['WWW-Authenticate'] = 'bar';
|
||||||
src['WWW-AUTHENTICATE'] = 'baz';
|
src['WWW-AUTHENTICATE'] = 'baz';
|
||||||
|
@ -8,7 +8,7 @@ const http2 = require('http2');
|
|||||||
|
|
||||||
const server = http2.createServer();
|
const server = http2.createServer();
|
||||||
|
|
||||||
const src = Object.create(null);
|
const src = { __proto__: null };
|
||||||
src.accept = [ 'abc', 'def' ];
|
src.accept = [ 'abc', 'def' ];
|
||||||
src.Accept = 'ghijklmnop';
|
src.Accept = 'ghijklmnop';
|
||||||
src['www-authenticate'] = 'foo';
|
src['www-authenticate'] = 'foo';
|
||||||
|
@ -11,8 +11,8 @@ const {
|
|||||||
Http2ServerResponse,
|
Http2ServerResponse,
|
||||||
} = http2;
|
} = http2;
|
||||||
|
|
||||||
const protoRequest = Object.create(Http2ServerRequest.prototype);
|
const protoRequest = { __proto__: Http2ServerRequest.prototype };
|
||||||
const protoResponse = Object.create(Http2ServerResponse.prototype);
|
const protoResponse = { __proto__: Http2ServerResponse.prototype };
|
||||||
|
|
||||||
assert.strictEqual(protoRequest instanceof Http2ServerRequest, true);
|
assert.strictEqual(protoRequest instanceof Http2ServerRequest, true);
|
||||||
assert.strictEqual(protoResponse instanceof Http2ServerResponse, true);
|
assert.strictEqual(protoResponse instanceof Http2ServerResponse, true);
|
||||||
|
@ -30,7 +30,7 @@ function makeUrl(headers) {
|
|||||||
const server = http2.createServer();
|
const server = http2.createServer();
|
||||||
server.on('stream', common.mustCall((stream, headers) => {
|
server.on('stream', common.mustCall((stream, headers) => {
|
||||||
|
|
||||||
const obj = Object.create(null);
|
const obj = { __proto__: null };
|
||||||
switch (remaining--) {
|
switch (remaining--) {
|
||||||
case 3: {
|
case 3: {
|
||||||
const url = new URL(makeUrl(headers));
|
const url = new URL(makeUrl(headers));
|
||||||
|
@ -11,7 +11,7 @@ const {
|
|||||||
[
|
[
|
||||||
undefined,
|
undefined,
|
||||||
{},
|
{},
|
||||||
Object.create(null),
|
{ __proto__: null },
|
||||||
new Date(),
|
new Date(),
|
||||||
new (class Foo {})(),
|
new (class Foo {})(),
|
||||||
].forEach((input) => {
|
].forEach((input) => {
|
||||||
|
@ -149,7 +149,7 @@ const {
|
|||||||
{
|
{
|
||||||
// Only own properties are used
|
// Only own properties are used
|
||||||
const base = { 'abc': 1 };
|
const base = { 'abc': 1 };
|
||||||
const headers = Object.create(base);
|
const headers = { __proto__: base };
|
||||||
headers[':status'] = 200;
|
headers[':status'] = 200;
|
||||||
headers.xyz = [1, 2, 3, 4];
|
headers.xyz = [1, 2, 3, 4];
|
||||||
headers.foo = [];
|
headers.foo = [];
|
||||||
|
@ -8,4 +8,4 @@ const assert = require('assert');
|
|||||||
// https://github.com/nodejs/node/issues/7592
|
// https://github.com/nodejs/node/issues/7592
|
||||||
const F = () => {};
|
const F = () => {};
|
||||||
F.prototype = {};
|
F.prototype = {};
|
||||||
assert(Object.create(F.prototype) instanceof F);
|
assert({ __proto__: F.prototype } instanceof F);
|
||||||
|
@ -12,7 +12,7 @@ const NOT_HTTP_QUOTED_STRING_CODE_POINT = '\n';
|
|||||||
const mime = new MIMEType('application/ecmascript; ');
|
const mime = new MIMEType('application/ecmascript; ');
|
||||||
const mime_descriptors = Object.getOwnPropertyDescriptors(mime);
|
const mime_descriptors = Object.getOwnPropertyDescriptors(mime);
|
||||||
const mime_proto = Object.getPrototypeOf(mime);
|
const mime_proto = Object.getPrototypeOf(mime);
|
||||||
const mime_impersonator = Object.create(mime_proto);
|
const mime_impersonator = { __proto__: mime_proto };
|
||||||
for (const key of Object.keys(mime_descriptors)) {
|
for (const key of Object.keys(mime_descriptors)) {
|
||||||
const descriptor = mime_descriptors[key];
|
const descriptor = mime_descriptors[key];
|
||||||
if (descriptor.get) {
|
if (descriptor.get) {
|
||||||
|
@ -26,7 +26,7 @@ fs.writeFileSync(dotfileWithExtension, 'console.log(__filename);', 'utf8');
|
|||||||
delete require.cache[file];
|
delete require.cache[file];
|
||||||
delete require.extensions['.bar'];
|
delete require.extensions['.bar'];
|
||||||
delete require.extensions['.foo.bar'];
|
delete require.extensions['.foo.bar'];
|
||||||
Module._pathCache = Object.create(null);
|
Module._pathCache = { __proto__: null };
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -40,7 +40,7 @@ fs.writeFileSync(dotfileWithExtension, 'console.log(__filename);', 'utf8');
|
|||||||
require(`${modulePath}.foo.bar`);
|
require(`${modulePath}.foo.bar`);
|
||||||
delete require.cache[file];
|
delete require.cache[file];
|
||||||
delete require.extensions['.foo.bar'];
|
delete require.extensions['.foo.bar'];
|
||||||
Module._pathCache = Object.create(null);
|
Module._pathCache = { __proto__: null };
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -50,7 +50,7 @@ fs.writeFileSync(dotfileWithExtension, 'console.log(__filename);', 'utf8');
|
|||||||
(err) => err.message.startsWith(`Cannot find module '${modulePath}'`)
|
(err) => err.message.startsWith(`Cannot find module '${modulePath}'`)
|
||||||
);
|
);
|
||||||
delete require.cache[file];
|
delete require.cache[file];
|
||||||
Module._pathCache = Object.create(null);
|
Module._pathCache = { __proto__: null };
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -61,7 +61,7 @@ fs.writeFileSync(dotfileWithExtension, 'console.log(__filename);', 'utf8');
|
|||||||
delete require.cache[file];
|
delete require.cache[file];
|
||||||
delete require.extensions['.bar'];
|
delete require.extensions['.bar'];
|
||||||
delete require.extensions['.foo.bar'];
|
delete require.extensions['.foo.bar'];
|
||||||
Module._pathCache = Object.create(null);
|
Module._pathCache = { __proto__: null };
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -72,7 +72,7 @@ fs.writeFileSync(dotfileWithExtension, 'console.log(__filename);', 'utf8');
|
|||||||
(err) => err.message.startsWith(`Cannot find module '${modulePath}'`)
|
(err) => err.message.startsWith(`Cannot find module '${modulePath}'`)
|
||||||
);
|
);
|
||||||
delete require.extensions['.foo.bar'];
|
delete require.extensions['.foo.bar'];
|
||||||
Module._pathCache = Object.create(null);
|
Module._pathCache = { __proto__: null };
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -80,7 +80,7 @@ fs.writeFileSync(dotfileWithExtension, 'console.log(__filename);', 'utf8');
|
|||||||
require(dotfile);
|
require(dotfile);
|
||||||
delete require.cache[dotfile];
|
delete require.cache[dotfile];
|
||||||
delete require.extensions['.bar'];
|
delete require.extensions['.bar'];
|
||||||
Module._pathCache = Object.create(null);
|
Module._pathCache = { __proto__: null };
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -90,5 +90,5 @@ fs.writeFileSync(dotfileWithExtension, 'console.log(__filename);', 'utf8');
|
|||||||
delete require.cache[dotfileWithExtension];
|
delete require.cache[dotfileWithExtension];
|
||||||
delete require.extensions['.bar'];
|
delete require.extensions['.bar'];
|
||||||
delete require.extensions['.foo.bar'];
|
delete require.extensions['.foo.bar'];
|
||||||
Module._pathCache = Object.create(null);
|
Module._pathCache = { __proto__: null };
|
||||||
}
|
}
|
||||||
|
@ -973,7 +973,7 @@ test('tokens:true should not include the default options after the args input',
|
|||||||
|
|
||||||
test('proto as default value must be ignored', () => {
|
test('proto as default value must be ignored', () => {
|
||||||
const args = [];
|
const args = [];
|
||||||
const options = Object.create(null);
|
const options = { __proto__: null };
|
||||||
|
|
||||||
// eslint-disable-next-line no-proto
|
// eslint-disable-next-line no-proto
|
||||||
options.__proto__ = { type: 'string', default: 'HELLO' };
|
options.__proto__ = { type: 'string', default: 'HELLO' };
|
||||||
|
@ -28,7 +28,7 @@ const inspect = require('util').inspect;
|
|||||||
const qs = require('querystring');
|
const qs = require('querystring');
|
||||||
|
|
||||||
function createWithNoPrototype(properties) {
|
function createWithNoPrototype(properties) {
|
||||||
const noProto = Object.create(null);
|
const noProto = { __proto__: null };
|
||||||
properties.forEach((property) => {
|
properties.forEach((property) => {
|
||||||
noProto[property.key] = property.value;
|
noProto[property.key] = property.value;
|
||||||
});
|
});
|
||||||
|
@ -10,13 +10,13 @@ const tls = require('tls');
|
|||||||
// Ensure accessing ._external doesn't hit an assert in the accessor method.
|
// Ensure accessing ._external doesn't hit an assert in the accessor method.
|
||||||
{
|
{
|
||||||
const pctx = tls.createSecureContext().context;
|
const pctx = tls.createSecureContext().context;
|
||||||
const cctx = Object.create(pctx);
|
const cctx = { __proto__: pctx };
|
||||||
assert.throws(() => cctx._external, TypeError);
|
assert.throws(() => cctx._external, TypeError);
|
||||||
pctx._external; // eslint-disable-line no-unused-expressions
|
pctx._external; // eslint-disable-line no-unused-expressions
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const pctx = tls.createSecurePair().credentials.context;
|
const pctx = tls.createSecurePair().credentials.context;
|
||||||
const cctx = Object.create(pctx);
|
const cctx = { __proto__: pctx };
|
||||||
assert.throws(() => cctx._external, TypeError);
|
assert.throws(() => cctx._external, TypeError);
|
||||||
pctx._external; // eslint-disable-line no-unused-expressions
|
pctx._external; // eslint-disable-line no-unused-expressions
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ deepStrictEqual(
|
|||||||
}
|
}
|
||||||
|
|
||||||
deepStrictEqual(translatePeerCertificate({ infoAccess: '' }),
|
deepStrictEqual(translatePeerCertificate({ infoAccess: '' }),
|
||||||
{ infoAccess: Object.create(null) });
|
{ infoAccess: { __proto__: null } });
|
||||||
deepStrictEqual(translatePeerCertificate({ infoAccess: null }),
|
deepStrictEqual(translatePeerCertificate({ infoAccess: null }),
|
||||||
{ infoAccess: null });
|
{ infoAccess: null });
|
||||||
{
|
{
|
||||||
@ -61,7 +61,7 @@ deepStrictEqual(translatePeerCertificate({ infoAccess: null }),
|
|||||||
'__proto__:mostly harmless\n' +
|
'__proto__:mostly harmless\n' +
|
||||||
'hasOwnProperty:not a function\n' +
|
'hasOwnProperty:not a function\n' +
|
||||||
'OCSP - URI:file:///etc/passwd\n';
|
'OCSP - URI:file:///etc/passwd\n';
|
||||||
const expected = Object.create(null);
|
const expected = { __proto__: null };
|
||||||
expected.__proto__ = ['mostly harmless'];
|
expected.__proto__ = ['mostly harmless'];
|
||||||
expected.hasOwnProperty = ['not a function'];
|
expected.hasOwnProperty = ['not a function'];
|
||||||
expected['OCSP - URI'] = ['file:///etc/passwd'];
|
expected['OCSP - URI'] = ['file:///etc/passwd'];
|
||||||
|
@ -6,7 +6,7 @@ const fs = require('fs');
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const util = require('util');
|
const util = require('util');
|
||||||
|
|
||||||
const tests = Object.create(null);
|
const tests = { __proto__: null };
|
||||||
|
|
||||||
let gid = 1;
|
let gid = 1;
|
||||||
let uid = 1;
|
let uid = 1;
|
||||||
|
@ -6,7 +6,7 @@ const fs = require('fs');
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const util = require('util');
|
const util = require('util');
|
||||||
|
|
||||||
const tests = Object.create(null);
|
const tests = { __proto__: null };
|
||||||
|
|
||||||
let gid = 1;
|
let gid = 1;
|
||||||
let uid = 1;
|
let uid = 1;
|
||||||
|
@ -4,7 +4,7 @@ const assert = require('assert');
|
|||||||
const url = require('url');
|
const url = require('url');
|
||||||
|
|
||||||
function createWithNoPrototype(properties = []) {
|
function createWithNoPrototype(properties = []) {
|
||||||
const noProto = Object.create(null);
|
const noProto = { __proto__: null };
|
||||||
properties.forEach((property) => {
|
properties.forEach((property) => {
|
||||||
noProto[property.key] = property.value;
|
noProto[property.key] = property.value;
|
||||||
});
|
});
|
||||||
|
@ -219,7 +219,7 @@ assert.strictEqual(util.format('%s', -Infinity), '-Infinity');
|
|||||||
function D() {
|
function D() {
|
||||||
C.call(this);
|
C.call(this);
|
||||||
}
|
}
|
||||||
D.prototype = Object.create(C.prototype);
|
D.prototype = { __proto__: C.prototype };
|
||||||
|
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
util.format('%s', new B()),
|
util.format('%s', new B()),
|
||||||
@ -264,7 +264,7 @@ assert.strictEqual(util.format('%s', -Infinity), '-Infinity');
|
|||||||
);
|
);
|
||||||
|
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
util.format('%s', Object.create(null)),
|
util.format('%s', { __proto__: null }),
|
||||||
'[Object: null prototype] {}'
|
'[Object: null prototype] {}'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ assert.strictEqual(
|
|||||||
`"${Array(75).fill(1)}'\\n" +\n '\\x1D\\n' +\n '\\x03\\x85\\x7F~\\x9F '`
|
`"${Array(75).fill(1)}'\\n" +\n '\\x1D\\n' +\n '\\x03\\x85\\x7F~\\x9F '`
|
||||||
);
|
);
|
||||||
assert.strictEqual(util.inspect([]), '[]');
|
assert.strictEqual(util.inspect([]), '[]');
|
||||||
assert.strictEqual(util.inspect(Object.create([])), 'Array {}');
|
assert.strictEqual(util.inspect({ __proto__: [] }), 'Array {}');
|
||||||
assert.strictEqual(util.inspect([1, 2]), '[ 1, 2 ]');
|
assert.strictEqual(util.inspect([1, 2]), '[ 1, 2 ]');
|
||||||
assert.strictEqual(util.inspect([1, [2, 3]]), '[ 1, [ 2, 3 ] ]');
|
assert.strictEqual(util.inspect([1, [2, 3]]), '[ 1, [ 2, 3 ] ]');
|
||||||
assert.strictEqual(util.inspect({}), '{}');
|
assert.strictEqual(util.inspect({}), '{}');
|
||||||
@ -796,7 +796,7 @@ assert.strictEqual(util.inspect(-5e-324), '-5e-324');
|
|||||||
});
|
});
|
||||||
|
|
||||||
// https://github.com/nodejs/node-v0.x-archive/issues/1941
|
// https://github.com/nodejs/node-v0.x-archive/issues/1941
|
||||||
assert.strictEqual(util.inspect(Object.create(Date.prototype)), 'Date {}');
|
assert.strictEqual(util.inspect({ __proto__: Date.prototype }), 'Date {}');
|
||||||
|
|
||||||
// https://github.com/nodejs/node-v0.x-archive/issues/1944
|
// https://github.com/nodejs/node-v0.x-archive/issues/1944
|
||||||
{
|
{
|
||||||
@ -1467,7 +1467,7 @@ if (typeof Symbol !== 'undefined') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const x = Object.create(null);
|
const x = { __proto__: null };
|
||||||
assert.strictEqual(util.inspect(x), '[Object: null prototype] {}');
|
assert.strictEqual(util.inspect(x), '[Object: null prototype] {}');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1631,7 +1631,7 @@ util.inspect(process);
|
|||||||
"Foo [bar] { foo: 'bar' }");
|
"Foo [bar] { foo: 'bar' }");
|
||||||
|
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
util.inspect(Object.create(Object.create(Foo.prototype), {
|
util.inspect(Object.create({ __proto__: Foo.prototype }, {
|
||||||
foo: { value: 'bar', enumerable: true }
|
foo: { value: 'bar', enumerable: true }
|
||||||
})),
|
})),
|
||||||
"Foo [bar] { foo: 'bar' }");
|
"Foo [bar] { foo: 'bar' }");
|
||||||
@ -2396,7 +2396,7 @@ assert.strictEqual(
|
|||||||
);
|
);
|
||||||
|
|
||||||
function StorageObject() {}
|
function StorageObject() {}
|
||||||
StorageObject.prototype = Object.create(null);
|
StorageObject.prototype = { __proto__: null };
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
util.inspect(new StorageObject()),
|
util.inspect(new StorageObject()),
|
||||||
'StorageObject <[Object: null prototype] {}> {}'
|
'StorageObject <[Object: null prototype] {}> {}'
|
||||||
@ -2406,17 +2406,17 @@ assert.strictEqual(
|
|||||||
Object.setPrototypeOf(obj, Number.prototype);
|
Object.setPrototypeOf(obj, Number.prototype);
|
||||||
assert.strictEqual(inspect(obj), "Number { '0': 1, '1': 2, '2': 3 }");
|
assert.strictEqual(inspect(obj), "Number { '0': 1, '1': 2, '2': 3 }");
|
||||||
|
|
||||||
Object.setPrototypeOf(obj, Object.create(null));
|
Object.setPrototypeOf(obj, { __proto__: null });
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
inspect(obj),
|
inspect(obj),
|
||||||
"Array <[Object: null prototype] {}> { '0': 1, '1': 2, '2': 3 }"
|
"Array <[Object: null prototype] {}> { '0': 1, '1': 2, '2': 3 }"
|
||||||
);
|
);
|
||||||
|
|
||||||
StorageObject.prototype = Object.create(null);
|
StorageObject.prototype = { __proto__: null };
|
||||||
Object.setPrototypeOf(StorageObject.prototype, Object.create(null));
|
Object.setPrototypeOf(StorageObject.prototype, { __proto__: null });
|
||||||
Object.setPrototypeOf(
|
Object.setPrototypeOf(
|
||||||
Object.getPrototypeOf(StorageObject.prototype),
|
Object.getPrototypeOf(StorageObject.prototype),
|
||||||
Object.create(null)
|
{ __proto__: null }
|
||||||
);
|
);
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
util.inspect(new StorageObject()),
|
util.inspect(new StorageObject()),
|
||||||
@ -2991,7 +2991,7 @@ assert.strictEqual(
|
|||||||
'}'
|
'}'
|
||||||
);
|
);
|
||||||
|
|
||||||
const obj = Object.create({ abc: true, def: 5, toString() {} });
|
const obj = { __proto__: { abc: true, def: 5, toString() {} } };
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
inspect(obj, { showHidden: true, colors: true }),
|
inspect(obj, { showHidden: true, colors: true }),
|
||||||
'{ \x1B[2mabc: \x1B[33mtrue\x1B[39m\x1B[22m, ' +
|
'{ \x1B[2mabc: \x1B[33mtrue\x1B[39m\x1B[22m, ' +
|
||||||
@ -3107,7 +3107,7 @@ assert.strictEqual(
|
|||||||
return this.stylized;
|
return this.stylized;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
`, Object.create(null));
|
`, { __proto__: null });
|
||||||
assert.strictEqual(target.ctx, undefined);
|
assert.strictEqual(target.ctx, undefined);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -132,19 +132,19 @@ for (const [ value, _method ] of [
|
|||||||
const bigInt64Array = new BigInt64Array(arrayBuffer);
|
const bigInt64Array = new BigInt64Array(arrayBuffer);
|
||||||
const bigUint64Array = new BigUint64Array(arrayBuffer);
|
const bigUint64Array = new BigUint64Array(arrayBuffer);
|
||||||
|
|
||||||
const fakeBuffer = Object.create(Buffer.prototype);
|
const fakeBuffer = { __proto__: Buffer.prototype };
|
||||||
const fakeDataView = Object.create(DataView.prototype);
|
const fakeDataView = { __proto__: DataView.prototype };
|
||||||
const fakeUint8Array = Object.create(Uint8Array.prototype);
|
const fakeUint8Array = { __proto__: Uint8Array.prototype };
|
||||||
const fakeUint8ClampedArray = Object.create(Uint8ClampedArray.prototype);
|
const fakeUint8ClampedArray = { __proto__: Uint8ClampedArray.prototype };
|
||||||
const fakeUint16Array = Object.create(Uint16Array.prototype);
|
const fakeUint16Array = { __proto__: Uint16Array.prototype };
|
||||||
const fakeUint32Array = Object.create(Uint32Array.prototype);
|
const fakeUint32Array = { __proto__: Uint32Array.prototype };
|
||||||
const fakeInt8Array = Object.create(Int8Array.prototype);
|
const fakeInt8Array = { __proto__: Int8Array.prototype };
|
||||||
const fakeInt16Array = Object.create(Int16Array.prototype);
|
const fakeInt16Array = { __proto__: Int16Array.prototype };
|
||||||
const fakeInt32Array = Object.create(Int32Array.prototype);
|
const fakeInt32Array = { __proto__: Int32Array.prototype };
|
||||||
const fakeFloat32Array = Object.create(Float32Array.prototype);
|
const fakeFloat32Array = { __proto__: Float32Array.prototype };
|
||||||
const fakeFloat64Array = Object.create(Float64Array.prototype);
|
const fakeFloat64Array = { __proto__: Float64Array.prototype };
|
||||||
const fakeBigInt64Array = Object.create(BigInt64Array.prototype);
|
const fakeBigInt64Array = { __proto__: BigInt64Array.prototype };
|
||||||
const fakeBigUint64Array = Object.create(BigUint64Array.prototype);
|
const fakeBigUint64Array = { __proto__: BigUint64Array.prototype };
|
||||||
|
|
||||||
const stealthyDataView =
|
const stealthyDataView =
|
||||||
Object.setPrototypeOf(new DataView(arrayBuffer), Uint8Array.prototype);
|
Object.setPrototypeOf(new DataView(arrayBuffer), Uint8Array.prototype);
|
||||||
|
@ -38,7 +38,7 @@ assert.strictEqual(util.isArray({}), false);
|
|||||||
assert.strictEqual(util.isArray({ push: function() {} }), false);
|
assert.strictEqual(util.isArray({ push: function() {} }), false);
|
||||||
assert.strictEqual(util.isArray(/regexp/), false);
|
assert.strictEqual(util.isArray(/regexp/), false);
|
||||||
assert.strictEqual(util.isArray(new Error()), false);
|
assert.strictEqual(util.isArray(new Error()), false);
|
||||||
assert.strictEqual(util.isArray(Object.create(Array.prototype)), false);
|
assert.strictEqual(util.isArray({ __proto__: Array.prototype }), false);
|
||||||
|
|
||||||
// isRegExp
|
// isRegExp
|
||||||
assert.strictEqual(util.isRegExp(/regexp/), true);
|
assert.strictEqual(util.isRegExp(/regexp/), true);
|
||||||
@ -48,7 +48,7 @@ assert.strictEqual(util.isRegExp(context('RegExp')()), true);
|
|||||||
assert.strictEqual(util.isRegExp({}), false);
|
assert.strictEqual(util.isRegExp({}), false);
|
||||||
assert.strictEqual(util.isRegExp([]), false);
|
assert.strictEqual(util.isRegExp([]), false);
|
||||||
assert.strictEqual(util.isRegExp(new Date()), false);
|
assert.strictEqual(util.isRegExp(new Date()), false);
|
||||||
assert.strictEqual(util.isRegExp(Object.create(RegExp.prototype)), false);
|
assert.strictEqual(util.isRegExp({ __proto__: RegExp.prototype }), false);
|
||||||
|
|
||||||
// isDate
|
// isDate
|
||||||
assert.strictEqual(util.isDate(new Date()), true);
|
assert.strictEqual(util.isDate(new Date()), true);
|
||||||
@ -58,7 +58,7 @@ assert.strictEqual(util.isDate(Date()), false);
|
|||||||
assert.strictEqual(util.isDate({}), false);
|
assert.strictEqual(util.isDate({}), false);
|
||||||
assert.strictEqual(util.isDate([]), false);
|
assert.strictEqual(util.isDate([]), false);
|
||||||
assert.strictEqual(util.isDate(new Error()), false);
|
assert.strictEqual(util.isDate(new Error()), false);
|
||||||
assert.strictEqual(util.isDate(Object.create(Date.prototype)), false);
|
assert.strictEqual(util.isDate({ __proto__: Date.prototype }), false);
|
||||||
|
|
||||||
// isError
|
// isError
|
||||||
assert.strictEqual(util.isError(new Error()), true);
|
assert.strictEqual(util.isError(new Error()), true);
|
||||||
@ -70,7 +70,7 @@ assert.strictEqual(util.isError(new (context('SyntaxError'))()), true);
|
|||||||
assert.strictEqual(util.isError({}), false);
|
assert.strictEqual(util.isError({}), false);
|
||||||
assert.strictEqual(util.isError({ name: 'Error', message: '' }), false);
|
assert.strictEqual(util.isError({ name: 'Error', message: '' }), false);
|
||||||
assert.strictEqual(util.isError([]), false);
|
assert.strictEqual(util.isError([]), false);
|
||||||
assert.strictEqual(util.isError(Object.create(Error.prototype)), true);
|
assert.strictEqual(util.isError({ __proto__: Error.prototype }), true);
|
||||||
|
|
||||||
// isObject
|
// isObject
|
||||||
assert.strictEqual(util.isObject({}), true);
|
assert.strictEqual(util.isObject({}), true);
|
||||||
@ -170,7 +170,7 @@ assert.strictEqual(util.toUSVString('string\ud801'), 'string\ufffd');
|
|||||||
);
|
);
|
||||||
assert.strictEqual(util.types.isNativeError([]), false);
|
assert.strictEqual(util.types.isNativeError([]), false);
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
util.types.isNativeError(Object.create(Error.prototype)),
|
util.types.isNativeError({ __proto__: Error.prototype }),
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
|
@ -21,11 +21,11 @@ let result = vm.runInContext('Object.hasOwnProperty(this, "propBase");',
|
|||||||
assert.strictEqual(result, false);
|
assert.strictEqual(result, false);
|
||||||
|
|
||||||
// Ref: https://github.com/nodejs/node/issues/5350
|
// Ref: https://github.com/nodejs/node/issues/5350
|
||||||
base = Object.create(null);
|
base = { __proto__: null };
|
||||||
base.x = 1;
|
base.x = 1;
|
||||||
base.y = 2;
|
base.y = 2;
|
||||||
|
|
||||||
sandbox = Object.create(base);
|
sandbox = { __proto__: base };
|
||||||
sandbox.z = 3;
|
sandbox.z = 3;
|
||||||
|
|
||||||
assert.deepStrictEqual(Object.keys(sandbox), ['z']);
|
assert.deepStrictEqual(Object.keys(sandbox), ['z']);
|
||||||
|
@ -85,7 +85,7 @@ const util = require('util');
|
|||||||
assert.strictEqual(util.inspect(m, { depth: -1 }), '[SourceTextModule]');
|
assert.strictEqual(util.inspect(m, { depth: -1 }), '[SourceTextModule]');
|
||||||
|
|
||||||
assert.throws(
|
assert.throws(
|
||||||
() => m[util.inspect.custom].call(Object.create(null)),
|
() => m[util.inspect.custom].call({ __proto__: null }),
|
||||||
{
|
{
|
||||||
code: 'ERR_VM_MODULE_NOT_MODULE',
|
code: 'ERR_VM_MODULE_NOT_MODULE',
|
||||||
message: 'Provided module is not an instance of Module'
|
message: 'Provided module is not an instance of Module'
|
||||||
|
@ -239,7 +239,7 @@ const { hasOpenSSL3 } = common;
|
|||||||
checkServerIdentity: (hostname, peerCert) => {
|
checkServerIdentity: (hostname, peerCert) => {
|
||||||
assert.strictEqual(hostname, 'example.com');
|
assert.strictEqual(hostname, 'example.com');
|
||||||
assert.deepStrictEqual(peerCert.infoAccess,
|
assert.deepStrictEqual(peerCert.infoAccess,
|
||||||
Object.assign(Object.create(null),
|
Object.assign({ __proto__: null },
|
||||||
expected.legacy));
|
expected.legacy));
|
||||||
|
|
||||||
// toLegacyObject() should also produce the same properties. However,
|
// toLegacyObject() should also produce the same properties. However,
|
||||||
@ -352,7 +352,7 @@ const { hasOpenSSL3 } = common;
|
|||||||
servername: 'example.com',
|
servername: 'example.com',
|
||||||
checkServerIdentity: (hostname, peerCert) => {
|
checkServerIdentity: (hostname, peerCert) => {
|
||||||
assert.strictEqual(hostname, 'example.com');
|
assert.strictEqual(hostname, 'example.com');
|
||||||
const expectedObject = Object.assign(Object.create(null),
|
const expectedObject = Object.assign({ __proto__: null },
|
||||||
expected.legacy);
|
expected.legacy);
|
||||||
assert.deepStrictEqual(peerCert.subject, expectedObject);
|
assert.deepStrictEqual(peerCert.subject, expectedObject);
|
||||||
// The issuer MUST be the same as the subject since the cert is
|
// The issuer MUST be the same as the subject since the cert is
|
||||||
|
@ -42,7 +42,7 @@ function FakeStream() {
|
|||||||
this.readable = true;
|
this.readable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FakeStream.prototype = Object.create(Stream.prototype);
|
FakeStream.prototype = { __proto__: Stream.prototype };
|
||||||
|
|
||||||
FakeStream.prototype.write = function(chunk) {
|
FakeStream.prototype.write = function(chunk) {
|
||||||
console.error(this.ID, 'write', this.wait);
|
console.error(this.ID, 'write', this.wait);
|
||||||
|
@ -35,7 +35,7 @@ import * as common from './common.mjs';
|
|||||||
import * as typeParser from './type-parser.mjs';
|
import * as typeParser from './type-parser.mjs';
|
||||||
import buildCSSForFlavoredJS from './buildCSSForFlavoredJS.mjs';
|
import buildCSSForFlavoredJS from './buildCSSForFlavoredJS.mjs';
|
||||||
|
|
||||||
const dynamicSizes = Object.create(null);
|
const dynamicSizes = { __proto__: null };
|
||||||
|
|
||||||
const { highlight, getLanguage } = highlightJs;
|
const { highlight, getLanguage } = highlightJs;
|
||||||
|
|
||||||
@ -398,8 +398,8 @@ function versionSort(a, b) {
|
|||||||
const DEPRECATION_HEADING_PATTERN = /^DEP\d+:/;
|
const DEPRECATION_HEADING_PATTERN = /^DEP\d+:/;
|
||||||
export function buildToc({ filename, apilinks }) {
|
export function buildToc({ filename, apilinks }) {
|
||||||
return (tree, file) => {
|
return (tree, file) => {
|
||||||
const idCounters = Object.create(null);
|
const idCounters = { __proto__: null };
|
||||||
const legacyIdCounters = Object.create(null);
|
const legacyIdCounters = { __proto__: null };
|
||||||
let toc = '';
|
let toc = '';
|
||||||
let depth = 0;
|
let depth = 0;
|
||||||
|
|
||||||
|
53
tools/eslint-rules/prefer-proto.js
Normal file
53
tools/eslint-rules/prefer-proto.js
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/**
|
||||||
|
* @fileoverview null objects can be created with `ObjectCreate(null)`, or with
|
||||||
|
* syntax: `{ __proto__: null }`. This linter rule forces use of
|
||||||
|
* syntax over ObjectCreate.
|
||||||
|
* @author Jordan Harband <ljharb@gmail.com>
|
||||||
|
*/
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
// Cribbed from `eslint-module-utils/declaredScope`
|
||||||
|
function declaredScope(context, name) {
|
||||||
|
const references = context.getScope().references;
|
||||||
|
const reference = references.find((x) => x.identifier.name === name);
|
||||||
|
if (!reference) return undefined;
|
||||||
|
return reference.resolved.scope.type;
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// Rule Definition
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
meta: {
|
||||||
|
fixable: 'code',
|
||||||
|
messages: {
|
||||||
|
error: 'Use `{ __proto__: {{value}} }` instead of `ObjectCreate({{value}})` or `Object.create({{value}})`.',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
create(context) {
|
||||||
|
return {
|
||||||
|
/* eslint max-len: 0 */
|
||||||
|
'CallExpression[arguments.length=1]:matches(\
|
||||||
|
[callee.type="Identifier"][callee.name="ObjectCreate"],\
|
||||||
|
[callee.type="MemberExpression"][callee.object.name="Object"][callee.property.name="create"]\
|
||||||
|
)'(node) {
|
||||||
|
if (node.callee.type === 'MemberExpression') {
|
||||||
|
const scope = declaredScope(context, node.callee.object);
|
||||||
|
if (scope && scope !== 'module' && scope !== 'global') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const value = context.getSourceCode().getText(node.arguments[0]);
|
||||||
|
context.report({
|
||||||
|
node,
|
||||||
|
messageId: 'error',
|
||||||
|
data: { value },
|
||||||
|
fix(fixer) {
|
||||||
|
return fixer.replaceText(node, `{ __proto__: ${value} }`);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
Loading…
x
Reference in New Issue
Block a user