diff options
author | XadillaX <i@2333.moe> | 2023-04-28 20:31:18 +0800 |
---|---|---|
committer | XadillaX <i@2333.moe> | 2023-05-13 22:17:05 +0800 |
commit | 23e6b12edb0b792b82ff948e3b6c5cb2038c17bf (patch) | |
tree | 9a57a0be52c9e59a5a8c8608c8c9b8d585266671 | |
parent | 21a2e901e7c16be8e1f97c374a181a40bd6bef38 (diff) | |
download | node-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.js | 14 |
1 files changed, 6 insertions, 8 deletions
@@ -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; |