Skip to content

lib: remove multiple noop definition #47327

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const {
} = codes;
const {
kEmptyObject,
noop,
} = require('internal/util');
const {
validateInteger,
Expand Down Expand Up @@ -809,7 +810,6 @@ function onParserTimeout(server, socket) {
socket.destroy();
}

const noop = () => {};
const badRequestResponse = Buffer.from(
`HTTP/1.1 400 ${STATUS_CODES[400]}\r\n` +
'Connection: close\r\n\r\n', 'ascii',
Expand Down
4 changes: 1 addition & 3 deletions lib/_tls_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const {
ArrayPrototypeForEach,
ArrayPrototypeJoin,
ArrayPrototypePush,
FunctionPrototype,
ObjectAssign,
ObjectDefineProperty,
ObjectSetPrototypeOf,
Expand All @@ -43,6 +42,7 @@ const {
assertCrypto,
deprecate,
kEmptyObject,
noop,
} = require('internal/util');

assertCrypto();
Expand Down Expand Up @@ -114,8 +114,6 @@ const kPskIdentityHint = Symbol('pskidentityhint');
const kPendingSession = Symbol('pendingSession');
const kIsVerified = Symbol('verified');

const noop = FunctionPrototype;

let ipServernameWarned = false;
let tlsTracingWarned = false;

Expand Down
4 changes: 1 addition & 3 deletions lib/internal/assert/calltracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const {
ArrayPrototypePush,
ArrayPrototypeSlice,
Error,
FunctionPrototype,
ObjectFreeze,
Proxy,
ReflectApply,
Expand All @@ -19,12 +18,11 @@ const {
},
} = require('internal/errors');
const AssertionError = require('internal/assert/assertion_error');
const { noop } = require('internal/util');
const {
validateUint32,
} = require('internal/validators');

const noop = FunctionPrototype;

class CallTrackerContext {
#expected;
#calls;
Expand Down
3 changes: 1 addition & 2 deletions lib/internal/cluster/child.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

const {
ArrayPrototypeJoin,
FunctionPrototype,
ObjectAssign,
ReflectApply,
SafeMap,
Expand All @@ -17,12 +16,12 @@ const Worker = require('internal/cluster/worker');
const { internal, sendHelper } = require('internal/cluster/utils');
const { exitCodes: { kNoFailure } } = internalBinding('errors');
const { TIMEOUT_MAX } = require('internal/timers');
const { noop } = require('internal/util');
const { setInterval, clearInterval } = require('timers');

const cluster = new EventEmitter();
const handles = new SafeMap();
const indexes = new SafeMap();
const noop = FunctionPrototype;

module.exports = cluster;

Expand Down
8 changes: 4 additions & 4 deletions lib/internal/modules/esm/module_job.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const {
ArrayPrototypeJoin,
ArrayPrototypePush,
ArrayPrototypeSome,
FunctionPrototype,
ObjectSetPrototypeOf,
PromiseResolve,
PromisePrototypeThen,
Expand All @@ -21,15 +20,16 @@ const {

const { ModuleWrap } = internalBinding('module_wrap');

const { decorateErrorStack } = require('internal/util');
const {
decorateErrorStack,
noop,
} = require('internal/util');
const {
getSourceMapsEnabled,
} = require('internal/source_map/source_map_cache');
const assert = require('internal/assert');
const resolvedPromise = PromiseResolve();

const noop = FunctionPrototype;

let hasPausedEntry = false;

const CJSGlobalLike = [
Expand Down
3 changes: 1 addition & 2 deletions lib/internal/repl/await.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const {
ArrayPrototypeJoin,
ArrayPrototypePop,
ArrayPrototypePush,
FunctionPrototype,
ObjectKeys,
RegExpPrototypeSymbolReplace,
StringPrototypeEndsWith,
Expand All @@ -21,12 +20,12 @@ const {
const parser = require('internal/deps/acorn/acorn/dist/acorn').Parser;
const walk = require('internal/deps/acorn/acorn-walk/dist/walk');
const { Recoverable } = require('internal/repl');
const { noop } = require('internal/util');

function isTopLevelDeclaration(state) {
return state.ancestors[state.ancestors.length - 2] === state.body;
}

const noop = FunctionPrototype;
const visitorsWithoutAncestors = {
ClassDeclaration(node, state, c) {
if (isTopLevelDeclaration(state)) {
Expand Down
4 changes: 1 addition & 3 deletions lib/internal/repl/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
const {
ArrayPrototypeJoin,
Boolean,
FunctionPrototype,
RegExpPrototypeSymbolSplit,
StringPrototypeTrim,
} = primordials;
Expand All @@ -16,10 +15,9 @@ let debug = require('internal/util/debuglog').debuglog('repl', (fn) => {
debug = fn;
});
const permission = require('internal/process/permission');
const { noop } = require('internal/util');
const { clearTimeout, setTimeout } = require('timers');

const noop = FunctionPrototype;

// XXX(chrisdickinson): The 15ms debounce value is somewhat arbitrary.
// The debounce is to guard against code pasted into the REPL.
const kDebounceHistoryMS = 15;
Expand Down
3 changes: 1 addition & 2 deletions lib/internal/test_runner/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const {
ArrayPrototypeSlice,
ArrayPrototypeSome,
ArrayPrototypeUnshift,
FunctionPrototype,
MathMax,
Number,
ObjectSeal,
Expand Down Expand Up @@ -41,6 +40,7 @@ const {
const {
createDeferredPromise,
kEmptyObject,
noop,
once: runOnce,
} = require('internal/util');
const { isPromise } = require('internal/util/types');
Expand All @@ -63,7 +63,6 @@ const kTestCodeFailure = 'testCodeFailure';
const kTestTimeoutFailure = 'testTimeoutFailure';
const kHookFailure = 'hookFailed';
const kDefaultTimeout = null;
const noop = FunctionPrototype;
const kShouldAbort = Symbol('kShouldAbort');
const kFilename = process.argv?.[1];
const kHookNames = ObjectSeal(['before', 'after', 'beforeEach', 'afterEach']);
Expand Down
4 changes: 4 additions & 0 deletions lib/internal/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const {
ArrayPrototypeSlice,
ArrayPrototypeSort,
Error,
FunctionPrototype,
FunctionPrototypeCall,
ObjectDefineProperties,
ObjectDefineProperty,
Expand Down Expand Up @@ -65,6 +66,8 @@ const { isNativeError } = internalBinding('types');

const noCrypto = !process.versions.openssl;

const noop = FunctionPrototype;

const experimentalWarnings = new SafeSet();

const colorRegExp = /\u001b\[\d\d?m/g; // eslint-disable-line no-control-regex
Expand Down Expand Up @@ -777,6 +780,7 @@ module.exports = {
join,
lazyDOMException,
lazyDOMExceptionClass,
noop,
normalizeEncoding,
once,
promisify,
Expand Down
3 changes: 1 addition & 2 deletions lib/internal/util/debuglog.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const {
StringPrototypeToUpperCase,
} = primordials;

const { noop } = require('internal/util');
const { inspect, format, formatWithOptions } = require('internal/util/inspect');

// `debugImpls` and `testEnabled` are deliberately not initialized so any call
Expand Down Expand Up @@ -43,8 +44,6 @@ function emitWarningIfNeeded(set) {
}
}

const noop = () => {};

function debuglogImpl(enabled, set) {
if (debugImpls[set] === undefined) {
if (enabled) {
Expand Down
7 changes: 4 additions & 3 deletions lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ const {
} = require('internal/errors');
const { isUint8Array } = require('internal/util/types');
const { queueMicrotask } = require('internal/process/task_queues');
const { kEmptyObject } = require('internal/util');
const {
kEmptyObject,
noop,
} = require('internal/util');
const {
validateAbortSignal,
validateBoolean,
Expand Down Expand Up @@ -139,8 +142,6 @@ const DEFAULT_IPV6_ADDR = '::';

const isWindows = process.platform === 'win32';

const noop = () => {};

const kPerfHooksNetConnectContext = Symbol('kPerfHooksNetConnectContext');

const dc = require('diagnostics_channel');
Expand Down