Skip to content

Commit e6685f9

Browse files
XadillaXtargos
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 <theratliter@gmail.com> Reviewed-By: Mestery <mestery@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 7ecc674 commit e6685f9

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

lib/vm.js

+6-8
Original file line numberDiff line numberDiff line change
@@ -235,14 +235,12 @@ function createContext(contextObject = {}, options = kEmptyObject) {
235235
validateBoolean(wasm, 'options.codeGeneration.wasm');
236236
}
237237

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

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

0 commit comments

Comments
 (0)