Skip to content

Commit 024b396

Browse files
LiviaMedeirosdanielleadams
authored andcommitted
vm: use kEmptyObject
PR-URL: #43159 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
1 parent e31baca commit 024b396

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

lib/internal/vm/module.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ const {
2424
isArrayBufferView,
2525
} = require('internal/util/types');
2626
const {
27-
getConstructorOf,
2827
customInspectSymbol,
2928
emitExperimentalWarning,
29+
getConstructorOf,
30+
kEmptyObject,
3031
} = require('internal/util');
3132
const {
3233
ERR_INVALID_ARG_TYPE,
@@ -199,7 +200,7 @@ class Module {
199200
this[kWrap].instantiate();
200201
}
201202

202-
async evaluate(options = {}) {
203+
async evaluate(options = kEmptyObject) {
203204
if (this[kWrap] === undefined) {
204205
throw new ERR_VM_MODULE_NOT_MODULE();
205206
}
@@ -258,7 +259,7 @@ class SourceTextModule extends Module {
258259
#error = kNoError;
259260
#statusOverride;
260261

261-
constructor(sourceText, options = {}) {
262+
constructor(sourceText, options = kEmptyObject) {
262263
validateString(sourceText, 'sourceText');
263264
validateObject(options, 'options');
264265

@@ -387,7 +388,7 @@ class SourceTextModule extends Module {
387388
}
388389

389390
class SyntheticModule extends Module {
390-
constructor(exportNames, evaluateCallback, options = {}) {
391+
constructor(exportNames, evaluateCallback, options = kEmptyObject) {
391392
if (!ArrayIsArray(exportNames) ||
392393
ArrayPrototypeSome(exportNames, (e) => typeof e !== 'string')) {
393394
throw new ERR_INVALID_ARG_TYPE('exportNames',

lib/vm.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,14 @@ const {
5757
validateUint32,
5858
} = require('internal/validators');
5959
const {
60-
kVmBreakFirstLineSymbol,
6160
emitExperimentalWarning,
61+
kEmptyObject,
62+
kVmBreakFirstLineSymbol,
6263
} = require('internal/util');
6364
const kParsingContext = Symbol('script parsing context');
6465

6566
class Script extends ContextifyScript {
66-
constructor(code, options = {}) {
67+
constructor(code, options = kEmptyObject) {
6768
code = `${code}`;
6869
if (typeof options === 'string') {
6970
options = { filename: options };
@@ -152,7 +153,7 @@ function validateContext(contextifiedObject) {
152153
}
153154
}
154155

155-
function getRunInContextArgs(options = {}) {
156+
function getRunInContextArgs(options = kEmptyObject) {
156157
validateObject(options, 'options');
157158

158159
let timeout = options.timeout;
@@ -212,7 +213,7 @@ function isContext(object) {
212213
}
213214

214215
let defaultContextNameIndex = 1;
215-
function createContext(contextObject = {}, options = {}) {
216+
function createContext(contextObject = {}, options = kEmptyObject) {
216217
if (isContext(contextObject)) {
217218
return contextObject;
218219
}
@@ -305,7 +306,7 @@ function runInThisContext(code, options) {
305306
return createScript(code, options).runInThisContext(options);
306307
}
307308

308-
function compileFunction(code, params, options = {}) {
309+
function compileFunction(code, params, options = kEmptyObject) {
309310
validateString(code, 'code');
310311
if (params !== undefined) {
311312
validateArray(params, 'params');
@@ -395,7 +396,7 @@ const measureMemoryExecutions = {
395396
eager: constants.measureMemory.execution.EAGER,
396397
};
397398

398-
function measureMemory(options = {}) {
399+
function measureMemory(options = kEmptyObject) {
399400
emitExperimentalWarning('vm.measureMemory');
400401
validateObject(options, 'options');
401402
const { mode = 'summary', execution = 'default' } = options;

0 commit comments

Comments
 (0)