mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
lib: remove unnecessary optional chaining
PR-URL: https://github.com/nodejs/node/pull/55728 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: LiviaMedeiros <livia@cirno.name> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
parent
34dc8e37bf
commit
7788999ac1
@ -958,10 +958,10 @@ function getMaxListeners(emitterOrTarget) {
|
||||
*/
|
||||
async function once(emitter, name, options = kEmptyObject) {
|
||||
validateObject(options, 'options');
|
||||
const signal = options?.signal;
|
||||
const { signal } = options;
|
||||
validateAbortSignal(signal, 'options.signal');
|
||||
if (signal?.aborted)
|
||||
throw new AbortError(undefined, { cause: signal?.reason });
|
||||
throw new AbortError(undefined, { cause: signal.reason });
|
||||
return new Promise((resolve, reject) => {
|
||||
const errorListener = (err) => {
|
||||
emitter.removeListener(name, resolver);
|
||||
@ -1049,7 +1049,7 @@ function on(emitter, event, options = kEmptyObject) {
|
||||
const signal = options.signal;
|
||||
validateAbortSignal(signal, 'options.signal');
|
||||
if (signal?.aborted)
|
||||
throw new AbortError(undefined, { cause: signal?.reason });
|
||||
throw new AbortError(undefined, { cause: signal.reason });
|
||||
// Support both highWaterMark and highWatermark for backward compatibility
|
||||
const highWatermark = options.highWaterMark ?? options.highWatermark ?? NumberMAX_SAFE_INTEGER;
|
||||
validateInteger(highWatermark, 'options.highWaterMark', 1);
|
||||
|
@ -340,7 +340,7 @@ function readFileAfterStat(err, stats) {
|
||||
|
||||
function checkAborted(signal, callback) {
|
||||
if (signal?.aborted) {
|
||||
callback(new AbortError(undefined, { cause: signal?.reason }));
|
||||
callback(new AbortError(undefined, { cause: signal.reason }));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -2204,7 +2204,7 @@ function lutimesSync(path, atime, mtime) {
|
||||
|
||||
function writeAll(fd, isUserFd, buffer, offset, length, signal, flush, callback) {
|
||||
if (signal?.aborted) {
|
||||
const abortError = new AbortError(undefined, { cause: signal?.reason });
|
||||
const abortError = new AbortError(undefined, { cause: signal.reason });
|
||||
if (isUserFd) {
|
||||
callback(abortError);
|
||||
} else {
|
||||
|
@ -471,7 +471,7 @@ async function fsCall(fn, handle, ...args) {
|
||||
|
||||
function checkAborted(signal) {
|
||||
if (signal?.aborted)
|
||||
throw new AbortError(undefined, { cause: signal?.reason });
|
||||
throw new AbortError(undefined, { cause: signal.reason });
|
||||
}
|
||||
|
||||
async function writeFileHandle(filehandle, data, signal, encoding) {
|
||||
|
@ -89,7 +89,7 @@ class ReadFileContext {
|
||||
|
||||
if (this.signal?.aborted) {
|
||||
return this.close(
|
||||
new AbortError(undefined, { cause: this.signal?.reason }));
|
||||
new AbortError(undefined, { cause: this.signal.reason }));
|
||||
}
|
||||
if (this.size === 0) {
|
||||
buffer = Buffer.allocUnsafeSlow(kReadFileUnknownBufferLength);
|
||||
|
@ -322,7 +322,7 @@ async function* watch(filename, options = kEmptyObject) {
|
||||
}
|
||||
|
||||
if (signal?.aborted)
|
||||
throw new AbortError(undefined, { cause: signal?.reason });
|
||||
throw new AbortError(undefined, { cause: signal.reason });
|
||||
|
||||
const handle = new FSEvent();
|
||||
let { promise, resolve, reject } = PromiseWithResolvers();
|
||||
|
@ -147,7 +147,7 @@ async function* setInterval(after, value, options = kEmptyObject) {
|
||||
const { signal, ref = true } = options;
|
||||
|
||||
if (signal?.aborted) {
|
||||
throw new AbortError(undefined, { cause: signal?.reason });
|
||||
throw new AbortError(undefined, { cause: signal.reason });
|
||||
}
|
||||
|
||||
let onCancel;
|
||||
|
Loading…
Reference in New Issue
Block a user