Skip to content

Commit

Permalink
vm,lib: refactor microtaskQueue assignment logic
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
XadillaX authored and MoLow committed Jul 6, 2023
1 parent 3460cf9 commit 4b2aa3d
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions lib/vm.js
Expand Up @@ -236,14 +236,12 @@ function createContext(contextObject = {}, options = kEmptyObject) {
validateBoolean(wasm, 'options.codeGeneration.wasm');
}

let microtaskQueue = null;
if (microtaskMode !== undefined) {
validateOneOf(microtaskMode, 'options.microtaskMode',
['afterEvaluate', undefined]);

if (microtaskMode === 'afterEvaluate')
microtaskQueue = new MicrotaskQueue();
}
validateOneOf(microtaskMode,
'options.microtaskMode',
['afterEvaluate', undefined]);
const microtaskQueue = microtaskMode === 'afterEvaluate' ?
new MicrotaskQueue() :
null;

makeContext(contextObject, name, origin, strings, wasm, microtaskQueue);
return contextObject;
Expand Down

0 comments on commit 4b2aa3d

Please sign in to comment.