summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXadillaX <i@2333.moe>2023-04-28 20:31:18 +0800
committerXadillaX <i@2333.moe>2023-05-13 22:17:05 +0800
commit23e6b12edb0b792b82ff948e3b6c5cb2038c17bf (patch)
tree9a57a0be52c9e59a5a8c8608c8c9b8d585266671
parent21a2e901e7c16be8e1f97c374a181a40bd6bef38 (diff)
downloadnode-new-23e6b12edb0b792b82ff948e3b6c5cb2038c17bf.tar.gz
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: https://github.com/nodejs/node/pull/47765 Reviewed-By: theanarkh <theratliter@gmail.com> Reviewed-By: Mestery <mestery@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
-rw-r--r--lib/vm.js14
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/vm.js b/lib/vm.js
index 1fdea84334..b48e79c282 100644
--- a/lib/vm.js
+++ b/lib/vm.js
@@ -235,14 +235,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;