lib: add trailing commas in internal/process

PR-URL: https://github.com/nodejs/node/pull/46687
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
This commit is contained in:
Antoine du Hamel 2023-02-18 18:56:43 +01:00 committed by GitHub
parent d42628d05a
commit cafc0b2b33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 44 additions and 43 deletions

View File

@ -286,6 +286,7 @@ overrides:
- ./internal/per_context/messageport.js - ./internal/per_context/messageport.js
- ./internal/policy/*.js - ./internal/policy/*.js
- ./internal/priority_queue.js - ./internal/priority_queue.js
- ./internal/process/*.js
- ./internal/readline/*.js - ./internal/readline/*.js
- ./internal/readme.md - ./internal/readme.md
- ./internal/repl/history.js - ./internal/repl/history.js

View File

@ -87,7 +87,7 @@ function evalScript(name, body, breakFirstLine, print, shouldLoadESM = false) {
importModuleDynamically(specifier, _, importAssertions) { importModuleDynamically(specifier, _, importAssertions) {
const loader = asyncESM.esmLoader; const loader = asyncESM.esmLoader;
return loader.import(specifier, baseUrl, importAssertions); return loader.import(specifier, baseUrl, importAssertions);
} },
})); }));
if (print) { if (print) {
const { log } = require('internal/console/global'); const { log } = require('internal/console/global');
@ -106,7 +106,7 @@ function evalScript(name, body, breakFirstLine, print, shouldLoadESM = false) {
const exceptionHandlerState = { const exceptionHandlerState = {
captureFn: null, captureFn: null,
reportFlag: false reportFlag: false,
}; };
function setUncaughtExceptionCaptureCallback(fn) { function setUncaughtExceptionCaptureCallback(fn) {
@ -213,5 +213,5 @@ module.exports = {
evalScript, evalScript,
onGlobalUncaughtException: createOnGlobalUncaughtException(), onGlobalUncaughtException: createOnGlobalUncaughtException(),
setUncaughtExceptionCaptureCallback, setUncaughtExceptionCaptureCallback,
hasUncaughtExceptionCaptureCallback hasUncaughtExceptionCaptureCallback,
}; };

View File

@ -38,8 +38,8 @@ const {
ERR_INVALID_ARG_TYPE, ERR_INVALID_ARG_TYPE,
ERR_INVALID_ARG_VALUE, ERR_INVALID_ARG_VALUE,
ERR_OUT_OF_RANGE, ERR_OUT_OF_RANGE,
ERR_UNKNOWN_SIGNAL ERR_UNKNOWN_SIGNAL,
} },
} = require('internal/errors'); } = require('internal/errors');
const format = require('internal/util/inspect').format; const format = require('internal/util/inspect').format;
const { const {
@ -108,7 +108,7 @@ function wrapProcessMethods(binding) {
cpuUsage: _cpuUsage, cpuUsage: _cpuUsage,
memoryUsage: _memoryUsage, memoryUsage: _memoryUsage,
rss, rss,
resourceUsage: _resourceUsage resourceUsage: _resourceUsage,
} = binding; } = binding;
function _rawDebug(...args) { function _rawDebug(...args) {
@ -145,14 +145,14 @@ function wrapProcessMethods(binding) {
if (prevValue) { if (prevValue) {
return { return {
user: cpuValues[0] - prevValue.user, user: cpuValues[0] - prevValue.user,
system: cpuValues[1] - prevValue.system system: cpuValues[1] - prevValue.system,
}; };
} }
// If no previous value passed in, return current value. // If no previous value passed in, return current value.
return { return {
user: cpuValues[0], user: cpuValues[0],
system: cpuValues[1] system: cpuValues[1],
}; };
} }
@ -172,7 +172,7 @@ function wrapProcessMethods(binding) {
heapTotal: memValues[1], heapTotal: memValues[1],
heapUsed: memValues[2], heapUsed: memValues[2],
external: memValues[3], external: memValues[3],
arrayBuffers: memValues[4] arrayBuffers: memValues[4],
}; };
} }
@ -255,7 +255,7 @@ function wrapProcessMethods(binding) {
ipcReceived: resourceValues[12], ipcReceived: resourceValues[12],
signalsCount: resourceValues[13], signalsCount: resourceValues[13],
voluntaryContextSwitches: resourceValues[14], voluntaryContextSwitches: resourceValues[14],
involuntaryContextSwitches: resourceValues[15] involuntaryContextSwitches: resourceValues[15],
}; };
} }
@ -266,7 +266,7 @@ function wrapProcessMethods(binding) {
resourceUsage, resourceUsage,
memoryUsage, memoryUsage,
kill, kill,
exit exit,
}; };
} }

View File

@ -57,5 +57,5 @@ module.exports = ObjectFreeze({
assertIntegrity(moduleURL, content) { assertIntegrity(moduleURL, content) {
this.manifest.assertIntegrity(moduleURL, content); this.manifest.assertIntegrity(moduleURL, content);
} },
}); });

View File

@ -40,7 +40,7 @@ function prepareMainThreadExecution(expandArgv1 = false, initializeModules = tru
prepareExecution({ prepareExecution({
expandArgv1, expandArgv1,
initializeModules, initializeModules,
isMainThread: true isMainThread: true,
}); });
} }
@ -48,7 +48,7 @@ function prepareWorkerThreadExecution() {
prepareExecution({ prepareExecution({
expandArgv1: false, expandArgv1: false,
initializeModules: false, // Will need to initialize it after policy setup initializeModules: false, // Will need to initialize it after policy setup
isMainThread: false isMainThread: false,
}); });
} }
@ -139,7 +139,7 @@ function patchProcessObject(expandArgv1) {
enumerable: true, enumerable: true,
// Only set it to true during snapshot building. // Only set it to true during snapshot building.
configurable: getOptionValue('--build-snapshot'), configurable: getOptionValue('--build-snapshot'),
value: process.argv[0] value: process.argv[0],
}); });
process.exitCode = undefined; process.exitCode = undefined;
@ -188,7 +188,7 @@ function addReadOnlyProcessAlias(name, option, enumerable = true) {
writable: false, writable: false,
configurable: true, configurable: true,
enumerable, enumerable,
value value,
}); });
} }
} }
@ -196,7 +196,7 @@ function addReadOnlyProcessAlias(name, option, enumerable = true) {
function setupWarningHandler() { function setupWarningHandler() {
const { const {
onWarning, onWarning,
resetForSerialization resetForSerialization,
} = require('internal/process/warning'); } = require('internal/process/warning');
if (getOptionValue('--warnings') && if (getOptionValue('--warnings') &&
process.env.NODE_NO_WARNINGS !== '1') { process.env.NODE_NO_WARNINGS !== '1') {
@ -245,7 +245,7 @@ function setupFetch() {
}, },
set(value) { set(value) {
exposeInterface(globalThis, name, value); exposeInterface(globalThis, name, value);
} },
}; };
} }
@ -291,7 +291,7 @@ function setupWebCrypto() {
{ __proto__: null, ...ObjectGetOwnPropertyDescriptor({ { __proto__: null, ...ObjectGetOwnPropertyDescriptor({
get crypto() { get crypto() {
throw new ERR_NO_CRYPTO(); throw new ERR_NO_CRYPTO();
} },
}, 'crypto') }); }, 'crypto') });
} }
@ -339,7 +339,7 @@ function initializeReport() {
get() { get() {
const { report } = require('internal/process/report'); const { report } = require('internal/process/report');
return report; return report;
} },
}); });
} }
@ -400,7 +400,7 @@ function setupInspectorHooks() {
if (internalBinding('config').hasInspector) { if (internalBinding('config').hasInspector) {
const { const {
enable, enable,
disable disable,
} = require('internal/inspector_async_hook'); } = require('internal/inspector_async_hook');
internalBinding('inspector').registerAsyncHook(enable, disable); internalBinding('inspector').registerAsyncHook(enable, disable);
} }
@ -455,7 +455,7 @@ function initializeDeprecations() {
writable: false, writable: false,
enumerable: true, enumerable: true,
configurable: true, configurable: true,
value: noBrowserGlobals value: noBrowserGlobals,
}); });
} }
@ -526,7 +526,7 @@ function readPolicyFromDisk() {
for (let i = 0; i < integrityEntries.length; i++) { for (let i = 0; i < integrityEntries.length; i++) {
const { const {
algorithm, algorithm,
value: expected value: expected,
} = integrityEntries[i]; } = integrityEntries[i];
const hash = createHash(algorithm); const hash = createHash(algorithm);
hash.update(src); hash.update(src);
@ -543,7 +543,7 @@ function readPolicyFromDisk() {
} }
} }
return { return {
manifestSrc: src, manifestURL: manifestURL.href manifestSrc: src, manifestURL: manifestURL.href,
}; };
} }
} }
@ -599,7 +599,7 @@ function loadPreloadModules() {
if (preloadModules && preloadModules.length > 0) { if (preloadModules && preloadModules.length > 0) {
const { const {
Module: { Module: {
_preloadModules _preloadModules,
}, },
} = require('internal/modules/cjs/loader'); } = require('internal/modules/cjs/loader');
_preloadModules(preloadModules); _preloadModules(preloadModules);
@ -614,5 +614,5 @@ module.exports = {
setupUserModules, setupUserModules,
prepareMainThreadExecution, prepareMainThreadExecution,
prepareWorkerThreadExecution, prepareWorkerThreadExecution,
markBootstrapComplete markBootstrapComplete,
}; };

View File

@ -15,9 +15,9 @@ const {
kPromiseRejectWithNoHandler, kPromiseRejectWithNoHandler,
kPromiseHandlerAddedAfterReject, kPromiseHandlerAddedAfterReject,
kPromiseResolveAfterResolved, kPromiseResolveAfterResolved,
kPromiseRejectAfterResolved kPromiseRejectAfterResolved,
}, },
setPromiseRejectCallback setPromiseRejectCallback,
} = internalBinding('task_queue'); } = internalBinding('task_queue');
const { deprecate } = require('internal/util'); const { deprecate } = require('internal/util');
@ -33,8 +33,8 @@ const {
popAsyncContext, popAsyncContext,
symbols: { symbols: {
async_id_symbol: kAsyncIdSymbol, async_id_symbol: kAsyncIdSymbol,
trigger_async_id_symbol: kTriggerAsyncIdSymbol trigger_async_id_symbol: kTriggerAsyncIdSymbol,
} },
} = require('internal/async_hooks'); } = require('internal/async_hooks');
const { isErrorStackTraceLimitWritable } = require('internal/errors'); const { isErrorStackTraceLimitWritable } = require('internal/errors');
@ -155,7 +155,7 @@ function unhandledRejection(promise, reason) {
uid: ++lastPromiseId, uid: ++lastPromiseId,
warned: false, warned: false,
domain: process.domain, domain: process.domain,
emit emit,
}); });
// This causes the promise to be referenced at least for one tick. // This causes the promise to be referenced at least for one tick.
ArrayPrototypePush(pendingUnhandledRejections, promise); ArrayPrototypePush(pendingUnhandledRejections, promise);

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
const { const {
ERR_SYNTHETIC ERR_SYNTHETIC,
} = require('internal/errors').codes; } = require('internal/errors').codes;
const { const {
validateBoolean, validateBoolean,
@ -92,7 +92,7 @@ const report = {
validateBoolean(trigger, 'trigger'); validateBoolean(trigger, 'trigger');
nr.setReportOnUncaughtException(trigger); nr.setReportOnUncaughtException(trigger);
} },
}; };
function addSignalHandler(sig) { function addSignalHandler(sig) {
@ -117,5 +117,5 @@ function signalHandler(sig) {
module.exports = { module.exports = {
addSignalHandler, addSignalHandler,
report report,
}; };

View File

@ -50,5 +50,5 @@ function stopListeningIfSignal(type) {
module.exports = { module.exports = {
startListeningIfSignal, startListeningIfSignal,
stopListeningIfSignal stopListeningIfSignal,
}; };

View File

@ -12,14 +12,14 @@ const {
// Used to run V8's micro task queue. // Used to run V8's micro task queue.
runMicrotasks, runMicrotasks,
setTickCallback, setTickCallback,
enqueueMicrotask enqueueMicrotask,
} = internalBinding('task_queue'); } = internalBinding('task_queue');
const { const {
setHasRejectionToWarn, setHasRejectionToWarn,
hasRejectionToWarn, hasRejectionToWarn,
listenForRejections, listenForRejections,
processPromiseRejections processPromiseRejections,
} = require('internal/process/promises'); } = require('internal/process/promises');
const { const {
@ -31,7 +31,7 @@ const {
emitBefore, emitBefore,
emitAfter, emitAfter,
emitDestroy, emitDestroy,
symbols: { async_id_symbol, trigger_async_id_symbol } symbols: { async_id_symbol, trigger_async_id_symbol },
} = require('internal/async_hooks'); } = require('internal/async_hooks');
const FixedQueue = require('internal/fixed_queue'); const FixedQueue = require('internal/fixed_queue');
@ -126,7 +126,7 @@ function nextTick(callback) {
[async_id_symbol]: asyncId, [async_id_symbol]: asyncId,
[trigger_async_id_symbol]: triggerAsyncId, [trigger_async_id_symbol]: triggerAsyncId,
callback, callback,
args args,
}; };
if (initHooksExist()) if (initHooksExist())
emitInit(asyncId, 'TickObject', triggerAsyncId, tickObject); emitInit(asyncId, 'TickObject', triggerAsyncId, tickObject);
@ -166,8 +166,8 @@ module.exports = {
setTickCallback(processTicksAndRejections); setTickCallback(processTicksAndRejections);
return { return {
nextTick, nextTick,
runNextTicks runNextTicks,
}; };
}, },
queueMicrotask queueMicrotask,
}; };

View File

@ -4,7 +4,7 @@
// run in the worker thread. // run in the worker thread.
const { const {
codes: { ERR_WORKER_UNSUPPORTED_OPERATION } codes: { ERR_WORKER_UNSUPPORTED_OPERATION },
} = require('internal/errors'); } = require('internal/errors');
function unavailable(name) { function unavailable(name) {
@ -17,5 +17,5 @@ function unavailable(name) {
} }
module.exports = { module.exports = {
unavailable unavailable,
}; };