Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: remove unnecessary optional chaining #55728

Merged
merged 3 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions lib/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@ async function once(emitter, name, options = kEmptyObject) {
const signal = options?.signal;
gurgunday marked this conversation as resolved.
Show resolved Hide resolved
validateAbortSignal(signal, 'options.signal');
if (signal?.aborted)
LiviaMedeiros marked this conversation as resolved.
Show resolved Hide resolved
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);
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/fs/promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/fs/read/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/fs/watchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion lib/timers/promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,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;
Expand Down
Loading