Skip to content

Commit ca8da5f

Browse files
LiviaMedeirostargos
authored andcommitted
vm: use kEmptyObject
PR-URL: #43159 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
1 parent 444d773 commit ca8da5f

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

lib/internal/vm/module.js

Lines changed: 5 additions & 4 deletions
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,
@@ -198,7 +199,7 @@ class Module {
198199
this[kWrap].instantiate();
199200
}
200201

201-
async evaluate(options = {}) {
202+
async evaluate(options = kEmptyObject) {
202203
if (this[kWrap] === undefined) {
203204
throw new ERR_VM_MODULE_NOT_MODULE();
204205
}
@@ -256,7 +257,7 @@ class SourceTextModule extends Module {
256257
#error = kNoError;
257258
#statusOverride;
258259

259-
constructor(sourceText, options = {}) {
260+
constructor(sourceText, options = kEmptyObject) {
260261
validateString(sourceText, 'sourceText');
261262
validateObject(options, 'options');
262263

@@ -385,7 +386,7 @@ class SourceTextModule extends Module {
385386
}
386387

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

lib/vm.js

Lines changed: 7 additions & 6 deletions
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)