Skip to content

Commit 4b2aa3d

Browse files
XadillaXMoLow
authored andcommitted
vm,lib: refactor microtaskQueue assignment logic
Simplify the assignment of the `microtaskQueue` variable in the `vm` module by replacing the conditional block with a more concise ternary operator. This change improves code readability and maintainability. PR-URL: #47765 Reviewed-By: theanarkh <[email protected]> Reviewed-By: Mestery <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 3460cf9 commit 4b2aa3d

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

lib/vm.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -236,14 +236,12 @@ function createContext(contextObject = {}, options = kEmptyObject) {
236236
validateBoolean(wasm, 'options.codeGeneration.wasm');
237237
}
238238

239-
let microtaskQueue = null;
240-
if (microtaskMode !== undefined) {
241-
validateOneOf(microtaskMode, 'options.microtaskMode',
242-
['afterEvaluate', undefined]);
243-
244-
if (microtaskMode === 'afterEvaluate')
245-
microtaskQueue = new MicrotaskQueue();
246-
}
239+
validateOneOf(microtaskMode,
240+
'options.microtaskMode',
241+
['afterEvaluate', undefined]);
242+
const microtaskQueue = microtaskMode === 'afterEvaluate' ?
243+
new MicrotaskQueue() :
244+
null;
247245

248246
makeContext(contextObject, name, origin, strings, wasm, microtaskQueue);
249247
return contextObject;

0 commit comments

Comments
 (0)