Skip to content

Commit

Permalink
deep-squash: rename nullObject to kEmptyObject
Browse files Browse the repository at this point in the history
  • Loading branch information
LiviaMedeiros committed May 20, 2022
1 parent b6bfaf1 commit 5e914f2
Show file tree
Hide file tree
Showing 41 changed files with 134 additions and 134 deletions.
6 changes: 3 additions & 3 deletions lib/_tls_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const {
const {
assertCrypto,
deprecate,
nullObject,
kEmptyObject,
} = require('internal/util');

assertCrypto();
Expand Down Expand Up @@ -1182,9 +1182,9 @@ function Server(options, listener) {

if (typeof options === 'function') {
listener = options;
options = nullObject;
options = kEmptyObject;
} else if (options == null || typeof options === 'object') {
options = options ?? nullObject;
options = options ?? kEmptyObject;
} else {
throw new ERR_INVALID_ARG_TYPE('options', 'Object', options);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/async_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const {
ERR_ASYNC_TYPE,
ERR_INVALID_ASYNC_ID
} = require('internal/errors').codes;
const { nullObject } = require('internal/util');
const { kEmptyObject } = require('internal/util');
const {
validateFunction,
validateString,
Expand Down Expand Up @@ -157,7 +157,7 @@ function createHook(fns) {
const destroyedSymbol = Symbol('destroyed');

class AsyncResource {
constructor(type, opts = nullObject) {
constructor(type, opts = kEmptyObject) {
validateString(type, 'type');

let triggerAsyncId = opts;
Expand Down
4 changes: 2 additions & 2 deletions lib/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const {
convertToValidSignal,
createDeferredPromise,
getSystemErrorName,
nullObject,
kEmptyObject,
promisify,
} = require('internal/util');
const { isArrayBufferView } = require('internal/util/types');
Expand Down Expand Up @@ -509,7 +509,7 @@ function normalizeSpawnArguments(file, args, options) {
}

if (options === undefined)
options = nullObject;
options = kEmptyObject;
else
validateObject(options, 'options');

Expand Down
4 changes: 2 additions & 2 deletions lib/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const {
} = primordials;
const kRejection = SymbolFor('nodejs.rejection');

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

const { inspect } = require('internal/util/inspect');

Expand Down Expand Up @@ -941,7 +941,7 @@ function getEventListeners(emitterOrTarget, type) {
* @param {{ signal: AbortSignal; }} [options]
* @returns {Promise}
*/
async function once(emitter, name, options = nullObject) {
async function once(emitter, name, options = kEmptyObject) {
const signal = options?.signal;
validateAbortSignal(signal, 'options.signal');
if (signal?.aborted)
Expand Down
18 changes: 9 additions & 9 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const { toPathIfFileURL } = require('internal/url');
const {
customPromisifyArgs,
deprecate,
nullObject,
kEmptyObject,
promisify,
} = require('internal/util');
const {
Expand Down Expand Up @@ -627,7 +627,7 @@ function read(fd, buffer, offsetOrOptions, length, position, callback) {
if (!isArrayBufferView(buffer)) {
// This is fs.read(fd, params, callback)
params = buffer;
({ buffer = Buffer.alloc(16384) } = params ?? nullObject);
({ buffer = Buffer.alloc(16384) } = params ?? kEmptyObject);
}
callback = offsetOrOptions;
} else {
Expand All @@ -640,7 +640,7 @@ function read(fd, buffer, offsetOrOptions, length, position, callback) {
offset = 0,
length = buffer.byteLength - offset,
position = null,
} = params ?? nullObject);
} = params ?? kEmptyObject);
}

validateBuffer(buffer);
Expand Down Expand Up @@ -705,7 +705,7 @@ function readSync(fd, buffer, offset, length, position) {

if (arguments.length <= 3) {
// Assume fs.readSync(fd, buffer, options)
const options = offset || nullObject;
const options = offset || kEmptyObject;

({
offset = 0,
Expand Down Expand Up @@ -833,7 +833,7 @@ function write(fd, buffer, offsetOrOptions, length, position, callback) {
offset = 0,
length = buffer.byteLength - offset,
position = null,
} = offsetOrOptions ?? nullObject);
} = offsetOrOptions ?? kEmptyObject);
}

if (offset == null || typeof offset === 'function') {
Expand Down Expand Up @@ -903,7 +903,7 @@ function writeSync(fd, buffer, offsetOrOptions, length, position) {
offset = 0,
length = buffer.byteLength - offset,
position = null,
} = offsetOrOptions ?? nullObject);
} = offsetOrOptions ?? kEmptyObject);
}
if (position === undefined)
position = null;
Expand Down Expand Up @@ -1461,7 +1461,7 @@ function readdirSync(path, options) {
function fstat(fd, options = { bigint: false }, callback) {
if (typeof options === 'function') {
callback = options;
options = nullObject;
options = kEmptyObject;
}
fd = getValidatedFd(fd);
callback = makeStatsCallback(callback);
Expand All @@ -1485,7 +1485,7 @@ function fstat(fd, options = { bigint: false }, callback) {
function lstat(path, options = { bigint: false }, callback) {
if (typeof options === 'function') {
callback = options;
options = nullObject;
options = kEmptyObject;
}
callback = makeStatsCallback(callback);
path = getValidatedPath(path);
Expand All @@ -1508,7 +1508,7 @@ function lstat(path, options = { bigint: false }, callback) {
function stat(path, options = { bigint: false }, callback) {
if (typeof options === 'function') {
callback = options;
options = nullObject;
options = kEmptyObject;
}
callback = makeStatsCallback(callback);
path = getValidatedPath(path);
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/blob.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const {
const {
createDeferredPromise,
customInspectSymbol: kInspect,
nullObject,
kEmptyObject,
} = require('internal/util');
const { inspect } = require('internal/util/inspect');

Expand Down Expand Up @@ -135,7 +135,7 @@ class Blob {
* }} [options]
* @constructs {Blob}
*/
constructor(sources = [], options = nullObject) {
constructor(sources = [], options = kEmptyObject) {
if (sources === null ||
typeof sources[SymbolIterator] !== 'function' ||
typeof sources === 'string') {
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/cluster/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const {

const EventEmitter = require('events');

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

module.exports = Worker;

Expand All @@ -19,7 +19,7 @@ function Worker(options) {
ReflectApply(EventEmitter, this, []);

if (options === null || typeof options !== 'object')
options = nullObject;
options = kEmptyObject;

this.exitedAfterDisconnect = undefined;

Expand Down
4 changes: 2 additions & 2 deletions lib/internal/crypto/keygen.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const {

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

const {
Expand Down Expand Up @@ -121,7 +121,7 @@ function handleError(ret) {
};
}

function parseKeyEncoding(keyType, options = nullObject) {
function parseKeyEncoding(keyType, options = kEmptyObject) {
const { publicKeyEncoding, privateKeyEncoding } = options;

let publicFormat, publicType;
Expand Down
14 changes: 7 additions & 7 deletions lib/internal/crypto/random.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const {

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

const { Buffer, kMaxLength } = require('buffer');
Expand Down Expand Up @@ -400,7 +400,7 @@ function randomUUID(options) {
validateObject(options, 'options');
const {
disableEntropyCache = false,
} = options || nullObject;
} = options || kEmptyObject;

validateBoolean(disableEntropyCache, 'options.disableEntropyCache');

Expand Down Expand Up @@ -465,7 +465,7 @@ function generatePrime(size, options, callback) {
validateInt32(size, 'size', 1);
if (typeof options === 'function') {
callback = options;
options = nullObject;
options = kEmptyObject;
}
validateFunction(callback, 'callback');

Expand All @@ -483,7 +483,7 @@ function generatePrime(size, options, callback) {
job.run();
}

function generatePrimeSync(size, options = nullObject) {
function generatePrimeSync(size, options = kEmptyObject) {
validateInt32(size, 'size', 1);

const job = createRandomPrimeJob(kCryptoJobSync, size, options);
Expand All @@ -507,7 +507,7 @@ function unsignedBigIntToBuffer(bigint, name) {
return Buffer.from(padded, 'hex');
}

function checkPrime(candidate, options = nullObject, callback) {
function checkPrime(candidate, options = kEmptyObject, callback) {
if (typeof candidate === 'bigint')
candidate = unsignedBigIntToBuffer(candidate, 'candidate');
if (!isAnyArrayBuffer(candidate) && !isArrayBufferView(candidate)) {
Expand All @@ -525,7 +525,7 @@ function checkPrime(candidate, options = nullObject, callback) {
}
if (typeof options === 'function') {
callback = options;
options = nullObject;
options = kEmptyObject;
}
validateFunction(callback, 'callback');
validateObject(options, 'options');
Expand All @@ -540,7 +540,7 @@ function checkPrime(candidate, options = nullObject, callback) {
job.run();
}

function checkPrimeSync(candidate, options = nullObject) {
function checkPrimeSync(candidate, options = kEmptyObject) {
if (typeof candidate === 'bigint')
candidate = unsignedBigIntToBuffer(candidate, 'candidate');
if (!isAnyArrayBuffer(candidate) && !isArrayBufferView(candidate)) {
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/crypto/x509.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const {

const {
customInspectSymbol: kInspect,
nullObject,
kEmptyObject,
} = require('internal/util');

const {
Expand Down Expand Up @@ -65,7 +65,7 @@ function isX509Certificate(value) {
return value[kInternalState] !== undefined;
}

function getFlags(options = nullObject) {
function getFlags(options = kEmptyObject) {
validateObject(options, 'options');
const {
subject = 'default', // Can be 'default', 'always', or 'never'
Expand Down
10 changes: 5 additions & 5 deletions lib/internal/encoding.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const {
getConstructorOf,
customInspectSymbol: inspect,
kEnumerableProperty,
nullObject,
kEmptyObject,
} = require('internal/util');

const {
Expand Down Expand Up @@ -378,7 +378,7 @@ function makeTextDecoderICU() {
} = internalBinding('icu');

class TextDecoder {
constructor(encoding = 'utf-8', options = nullObject) {
constructor(encoding = 'utf-8', options = kEmptyObject) {
encoding = `${encoding}`;
validateObject(options, 'options', {
nullable: true,
Expand Down Expand Up @@ -407,7 +407,7 @@ function makeTextDecoderICU() {
}


decode(input = empty, options = nullObject) {
decode(input = empty, options = kEmptyObject) {
validateDecoder(this);
if (isAnyArrayBuffer(input)) {
input = lazyBuffer().from(input);
Expand Down Expand Up @@ -452,7 +452,7 @@ function makeTextDecoderJS() {
}

class TextDecoder {
constructor(encoding = 'utf-8', options = nullObject) {
constructor(encoding = 'utf-8', options = kEmptyObject) {
encoding = `${encoding}`;
validateObject(options, 'options', {
nullable: true,
Expand Down Expand Up @@ -480,7 +480,7 @@ function makeTextDecoderJS() {
this[kBOMSeen] = false;
}

decode(input = empty, options = nullObject) {
decode(input = empty, options = kEmptyObject) {
validateDecoder(this);
if (isAnyArrayBuffer(input)) {
input = lazyBuffer().from(input);
Expand Down
8 changes: 4 additions & 4 deletions lib/internal/event_target.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const { validateObject, validateString } = require('internal/validators');
const {
customInspectSymbol,
kEnumerableProperty,
nullObject,
kEmptyObject,
} = require('internal/util');
const { inspect } = require('util');

Expand Down Expand Up @@ -455,7 +455,7 @@ class EventTarget {
* signal?: AbortSignal
* }} [options]
*/
addEventListener(type, listener, options = nullObject) {
addEventListener(type, listener, options = kEmptyObject) {
if (!isEventTarget(this))
throw new ERR_INVALID_THIS('EventTarget');
if (arguments.length < 2)
Expand Down Expand Up @@ -542,7 +542,7 @@ class EventTarget {
* capture?: boolean,
* }} [options]
*/
removeEventListener(type, listener, options = nullObject) {
removeEventListener(type, listener, options = kEmptyObject) {
if (!isEventTarget(this))
throw new ERR_INVALID_THIS('EventTarget');
if (!shouldAddListener(listener))
Expand Down Expand Up @@ -870,7 +870,7 @@ function validateEventListenerOptions(options) {
return { capture: options };

if (options === null)
return nullObject;
return kEmptyObject;
validateObject(options, 'options', {
allowArray: true, allowFunction: true,
});
Expand Down
Loading

0 comments on commit 5e914f2

Please sign in to comment.