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 <theratliter@gmail.com> Reviewed-By: Mestery <mestery@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 3460cf9 commit 4b2aa3d

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

‎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-
letmicrotaskQueue=null;
240-
if(microtaskMode!==undefined){
241-
validateOneOf(microtaskMode,'options.microtaskMode',
242-
['afterEvaluate',undefined]);
243-
244-
if(microtaskMode==='afterEvaluate')
245-
microtaskQueue=newMicrotaskQueue();
246-
}
239+
validateOneOf(microtaskMode,
240+
'options.microtaskMode',
241+
['afterEvaluate',undefined]);
242+
constmicrotaskQueue=microtaskMode==='afterEvaluate' ?
243+
newMicrotaskQueue() :
244+
null;
247245

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

0 commit comments

Comments
 (0)