Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/diagnostics_channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const { triggerUncaughtException } = internalBinding('errors');
const dc_binding = internalBinding('diagnostics_channel');
const { subscribers: subscriberCounts } = dc_binding;

const { WeakReference } = require('internal/util');
const { WeakReference, kEmptyObject } = require('internal/util');
const { isPromise } = require('internal/util/types');

// Can't delete when weakref count reaches 0 as it could increment again.
Expand Down Expand Up @@ -390,7 +390,7 @@ class BoundedChannel {
return done;
}

withScope(context = {}) {
withScope(context = kEmptyObject) {
return new BoundedChannelScope(this, context);
}

Expand Down Expand Up @@ -514,7 +514,7 @@ class TracingChannel {
return done;
}

traceSync(fn, context = {}, thisArg, ...args) {
traceSync(fn, context = { __proto__: null }, thisArg, ...args) {
if (!this.hasSubscribers) {
return ReflectApply(fn, thisArg, args);
}
Expand All @@ -534,7 +534,7 @@ class TracingChannel {
}
}

tracePromise(fn, context = {}, thisArg, ...args) {
tracePromise(fn, context = { __proto__: null }, thisArg, ...args) {
if (!this.hasSubscribers) {
const result = ReflectApply(fn, thisArg, args);
if (typeof result?.then !== 'function') {
Expand Down Expand Up @@ -589,7 +589,7 @@ class TracingChannel {
}
}

traceCallback(fn, position = -1, context = {}, thisArg, ...args) {
traceCallback(fn, position = -1, context = kEmptyObject, thisArg, ...args) {
if (!this.hasSubscribers) {
return ReflectApply(fn, thisArg, args);
}
Expand Down
16 changes: 8 additions & 8 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -1840,7 +1840,7 @@ function readdirSync(path, options) {
* ) => any} [callback]
* @returns {void}
*/
function fstat(fd, options = { bigint: false }, callback) {
function fstat(fd, options = { __proto__: null, bigint: false }, callback) {
if (typeof options === 'function') {
callback = options;
options = kEmptyObject;
Expand All @@ -1867,7 +1867,7 @@ function fstat(fd, options = { bigint: false }, callback) {
* ) => any} callback
* @returns {void}
*/
function lstat(path, options = { bigint: false }, callback) {
function lstat(path, options = { __proto__: null, bigint: false }, callback) {
if (typeof options === 'function') {
callback = options;
options = kEmptyObject;
Expand Down Expand Up @@ -1899,7 +1899,7 @@ function lstat(path, options = { bigint: false }, callback) {
* ) => any} callback
* @returns {void}
*/
function stat(path, options = { bigint: false, throwIfNoEntry: true }, callback) {
function stat(path, options = { __proto__: null, bigint: false, throwIfNoEntry: true }, callback) {
if (typeof options === 'function') {
callback = options;
options = kEmptyObject;
Expand All @@ -1922,7 +1922,7 @@ function stat(path, options = { bigint: false, throwIfNoEntry: true }, callback)
binding.stat(getValidatedPath(path), options.bigint, req, options.throwIfNoEntry);
}

function statfs(path, options = { bigint: false }, callback) {
function statfs(path, options = { __proto__: null, bigint: false }, callback) {
if (typeof options === 'function') {
callback = options;
options = kEmptyObject;
Expand Down Expand Up @@ -1957,7 +1957,7 @@ function statfs(path, options = { bigint: false }, callback) {
* @param {{ bigint?: boolean; }} [options]
* @returns {Stats | undefined}
*/
function fstatSync(fd, options = { bigint: false }) {
function fstatSync(fd, options = { __proto__: null, bigint: false }) {
const h = vfsState.handlers;
if (h !== null) {
const result = h.fstatSync(fd);
Expand All @@ -1980,7 +1980,7 @@ function fstatSync(fd, options = { bigint: false }) {
* }} [options]
* @returns {Stats | undefined}
*/
function lstatSync(path, options = { bigint: false, throwIfNoEntry: true }) {
function lstatSync(path, options = { __proto__: null, bigint: false, throwIfNoEntry: true }) {
const h = vfsState.handlers;
if (h !== null) {
const result = h.lstatSync(path, options);
Expand Down Expand Up @@ -2014,7 +2014,7 @@ function lstatSync(path, options = { bigint: false, throwIfNoEntry: true }) {
* }} [options]
* @returns {Stats}
*/
function statSync(path, options = { bigint: false, throwIfNoEntry: true }) {
function statSync(path, options = { __proto__: null, bigint: false, throwIfNoEntry: true }) {
const h = vfsState.handlers;
if (h !== null) {
const result = h.statSync(path, options);
Expand All @@ -2032,7 +2032,7 @@ function statSync(path, options = { bigint: false, throwIfNoEntry: true }) {
return getStatsFromBinding(stats);
}

function statfsSync(path, options = { bigint: false }) {
function statfsSync(path, options = { __proto__: null, bigint: false }) {
const h = vfsState.handlers;
if (h !== null) {
const result = h.statfsSync(path, options);
Expand Down
3 changes: 2 additions & 1 deletion lib/internal/async_local_storage/async_context_frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const AsyncContextFrame = require('internal/async_context_frame');
const { AsyncResource } = require('async_hooks');

const RunScope = require('internal/async_local_storage/run_scope');
const { kEmptyObject } = require('internal/util');

class AsyncLocalStorage {
#defaultValue = undefined;
Expand All @@ -26,7 +27,7 @@ class AsyncLocalStorage {
/**
* @param {AsyncLocalStorageOptions} [options]
*/
constructor(options = {}) {
constructor(options = kEmptyObject) {
validateObject(options, 'options');
this.#defaultValue = options.defaultValue;

Expand Down
3 changes: 2 additions & 1 deletion lib/internal/async_local_storage/async_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const {
} = require('async_hooks');

const RunScope = require('internal/async_local_storage/run_scope');
const { kEmptyObject } = require('internal/util');

const storageList = [];
const storageHook = createHook({
Expand All @@ -44,7 +45,7 @@ class AsyncLocalStorage {
/**
* @param {AsyncLocalStorageOptions} [options]
*/
constructor(options = {}) {
constructor(options = kEmptyObject) {
this.kResourceStore = Symbol('kResourceStore');
this.enabled = false;
validateObject(options, 'options');
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/blob.js
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ function createBlobReaderStream(reader) {
// unbounded memory growth when the DataQueue has a large burst of data.
const kMaxBatchChunks = 16;

async function* createBlobReaderIterable(reader, options = {}) {
async function* createBlobReaderIterable(reader, options = kEmptyObject) {
const { getReadError } = options;
let wakeup = PromiseWithResolvers();
reader.setWakeup(wakeup.resolve);
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/crypto/cipher.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const assert = require('internal/assert');

const LazyTransform = require('internal/streams/lazy_transform');

const { normalizeEncoding } = require('internal/util');
const { normalizeEncoding, kEmptyObject } = require('internal/util');

const { StringDecoder } = require('string_decoder');

Expand Down Expand Up @@ -255,7 +255,7 @@ addCipherPrototypeFunctions(Decipheriv);

const kMinNid = 1;
const kMaxNid = 2_147_483_647;
function getCipherInfo(nameOrNid, options = {}) {
function getCipherInfo(nameOrNid, options = kEmptyObject) {
validateObject(options, 'options');
let { keyLength, ivLength } = options;
if (keyLength !== undefined) {
Expand Down
8 changes: 4 additions & 4 deletions lib/internal/fs/promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -1715,7 +1715,7 @@ async function symlink(target, path, type) {
);
}

async function fstat(handle, options = { bigint: false }) {
async function fstat(handle, options = { __proto__: null, bigint: false }) {
const result = await PromisePrototypeThen(
binding.fstat(handle.fd, options.bigint, kUsePromises),
undefined,
Expand All @@ -1724,7 +1724,7 @@ async function fstat(handle, options = { bigint: false }) {
return getStatsFromBinding(result);
}

async function lstat(path, options = { bigint: false }) {
async function lstat(path, options = { __proto__: null, bigint: false }) {
const h = vfsState.handlers;
if (h !== null) {
const promise = h.lstat(path, options);
Expand All @@ -1743,7 +1743,7 @@ async function lstat(path, options = { bigint: false }) {
return getStatsFromBinding(result);
}

async function stat(path, options = { bigint: false, throwIfNoEntry: true }) {
async function stat(path, options = { __proto__: null, bigint: false, throwIfNoEntry: true }) {
const h = vfsState.handlers;
if (h !== null) {
const promise = h.stat(path, options);
Expand All @@ -1761,7 +1761,7 @@ async function stat(path, options = { bigint: false, throwIfNoEntry: true }) {
return getStatsFromBinding(result);
}

async function statfs(path, options = { bigint: false }) {
async function statfs(path, options = { __proto__: null, bigint: false }) {
const h = vfsState.handlers;
if (h !== null) {
const result = h.statfs(path, options);
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/http2/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -3813,7 +3813,7 @@ function getUnpackedSettings(buf, options = kEmptyObject) {
return settings;
}

function performServerHandshake(socket, options = {}) {
function performServerHandshake(socket, options = kEmptyObject) {
options = initializeOptions(options);
return new ServerHttp2Session(options, socket, undefined);
}
Expand Down
3 changes: 2 additions & 1 deletion lib/internal/inspector/network_http.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const {
} = require('internal/inspector/network');
const { Network } = require('inspector');
const EventEmitter = require('events');
const { kEmptyObject } = require('internal/util');

const kRequestUrl = Symbol('kRequestUrl');

Expand All @@ -36,7 +37,7 @@ function getRequestURL(request, host) {
}

// Convert a Headers object (Map<string, number | string | string[]>) to a plain object (Map<string, string>)
const convertHeaderObject = (headers = {}) => {
const convertHeaderObject = (headers = kEmptyObject) => {
// The 'host' header that contains the host and port of the URL.
let host;
let charset;
Expand Down
3 changes: 2 additions & 1 deletion lib/internal/inspector/network_http2.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ const {
} = internalBinding('http2').constants;
const EventEmitter = require('events');
const { Buffer } = require('buffer');
const { kEmptyObject } = require('internal/util');

const kRequestUrl = Symbol('kRequestUrl');

// Convert a Headers object (Map<string, number | string | string[]>) to a plain object (Map<string, string>)
function convertHeaderObject(headers = {}) {
function convertHeaderObject(headers = kEmptyObject) {
let scheme;
let authority;
let path;
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/modules/esm/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ class AsyncLoaderHooksOnLoaderHookWorker {
* @param {object} context Metadata about the module
* @returns {Promise<{ format: ModuleFormat, source: ModuleSource }>}
*/
async load(url, context = {}) {
async load(url, context = kEmptyObject) {
const chain = this.#chains.load;
const meta = {
chainFinished: null,
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/modules/esm/resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const { getOptionValue } = require('internal/options');
// Do not eagerly grab .manifest, it may be in TDZ
const { sep, posix: { relative: relativePosixPath }, resolve } = require('path');
const { URL, pathToFileURL, fileURLToPath, isURL, URLParse } = require('internal/url');
const { getCWDURL, setOwnProperty } = require('internal/util');
const { getCWDURL, setOwnProperty, kEmptyObject } = require('internal/util');
const { canParse: URLCanParse } = internalBinding('url');
const { legacyMainResolve: FSLegacyMainResolve } = internalBinding('fs');
const {
Expand Down Expand Up @@ -944,7 +944,7 @@ function throwIfInvalidParentURL(parentURL) {
* @param {string[]} [context.conditions] - The conditions for resolving the specifier.
* @returns {{url: string, format?: string}}
*/
function defaultResolve(specifier, context = {}) {
function defaultResolve(specifier, context = kEmptyObject) {
let { parentURL, conditions } = context;
throwIfInvalidParentURL(parentURL);

Expand Down
4 changes: 2 additions & 2 deletions lib/internal/perf/observe.js
Original file line number Diff line number Diff line change
Expand Up @@ -543,14 +543,14 @@ function hasObserver(type) {
}


function startPerf(target, key, context = {}) {
function startPerf(target, key, context = kEmptyObject) {
target[key] = {
...context,
startTime: now(),
};
}

function stopPerf(target, key, context = {}) {
function stopPerf(target, key, context = kEmptyObject) {
const ctx = target[key];
if (!ctx) {
return;
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/readline/emitKeypressEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const ESCAPE_CODE_TIMEOUT = 500;
* accepts a readable Stream instance and makes it emit "keypress" events
*/

function emitKeypressEvents(stream, iface = {}) {
function emitKeypressEvents(stream, iface = { __proto__: null }) {
if (stream[KEYPRESS_DECODER]) return;

stream[KEYPRESS_DECODER] = new StringDecoder('utf8');
Expand Down
3 changes: 2 additions & 1 deletion lib/internal/streams/fast-utf8-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const {

const {
sleep,
kEmptyObject,
} = require('internal/util');

const {
Expand Down Expand Up @@ -131,7 +132,7 @@ class Utf8Stream extends EventEmitter {
contentMode = kContentModeUtf8,
mode,
// Provides for a custom fs implementation. Mostly useful for testing.
fs: overrideFs = {},
fs: overrideFs = kEmptyObject,
} = options;

super();
Expand Down
3 changes: 2 additions & 1 deletion lib/internal/v8/cpu_profiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const {
MathFloor,
} = primordials;

const { kEmptyObject } = require('internal/util');
const {
validateNumber,
validateObject,
Expand All @@ -14,7 +15,7 @@ const kMaxSamplingIntervalUs = 0x7FFFFFFF;
const kMaxSamplingIntervalMs = kMaxSamplingIntervalUs / kMicrosPerMilli;
const kMaxSamplesUnlimited = 0xFFFF_FFFF;

function normalizeCpuProfileOptions(options = {}) {
function normalizeCpuProfileOptions(options = kEmptyObject) {
validateObject(options, 'options');

// TODO(ishabi): add support for 'mode' and 'filterContext' options
Expand Down
3 changes: 2 additions & 1 deletion lib/internal/v8/heap_profile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

const { kEmptyObject } = require('internal/util');
const {
validateBoolean,
validateInteger,
Expand All @@ -14,7 +15,7 @@ const {
kSamplingIncludeObjectsCollectedByMinorGC,
} = internalBinding('v8');

function normalizeHeapProfileOptions(options = {}) {
function normalizeHeapProfileOptions(options = kEmptyObject) {
validateObject(options, 'options');
const {
sampleInterval = 512 * 1024,
Expand Down
7 changes: 4 additions & 3 deletions lib/internal/vfs/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const {
} = internalBinding('constants');

const { getStatsFromBinding } = require('internal/fs/utils');
const { kEmptyObject } = require('internal/util');

// Default block size for virtual files (4KB)
const kDefaultBlockSize = 4096;
Expand Down Expand Up @@ -91,7 +92,7 @@ function fillBigIntStatsArray(
* @param {boolean} [options.bigint] Return BigIntStats
* @returns {Stats}
*/
function createFileStats(size, options = {}) {
function createFileStats(size, options = kEmptyObject) {
const now = DateNow();
const mode = (options.mode ?? 0o644) | S_IFREG;
const nlink = options.nlink ?? 1;
Expand Down Expand Up @@ -150,7 +151,7 @@ function createFileStats(size, options = {}) {
* @param {number} [options.birthtimeMs] Birth time in ms
* @returns {Stats}
*/
function createDirectoryStats(options = {}) {
function createDirectoryStats(options = kEmptyObject) {
const now = DateNow();
const mode = (options.mode ?? 0o755) | S_IFDIR;
const uid = options.uid ?? (process.getuid?.() ?? 0);
Expand Down Expand Up @@ -208,7 +209,7 @@ function createDirectoryStats(options = {}) {
* @param {number} [options.birthtimeMs] Birth time in ms
* @returns {Stats}
*/
function createSymlinkStats(size, options = {}) {
function createSymlinkStats(size, options = kEmptyObject) {
const now = DateNow();
const mode = (options.mode ?? 0o777) | S_IFLNK;
const uid = options.uid ?? (process.getuid?.() ?? 0);
Expand Down
Loading
Loading