From aecbe368f742095585e3cfb4f30563b92fa1bb14 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Fri, 14 Dec 2018 22:12:37 -0500 Subject: [PATCH] vm: simplify Script constructor options validation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit combines two related if statements into an if-else statement. PR-URL: https://github.com/nodejs/node/pull/25054 Reviewed-By: Michaƫl Zasso Reviewed-By: Luigi Pinca --- lib/vm.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/vm.js b/lib/vm.js index c8c6f0f7e9473d..02b3f0bce423bc 100644 --- a/lib/vm.js +++ b/lib/vm.js @@ -45,8 +45,7 @@ class Script extends ContextifyScript { code = `${code}`; if (typeof options === 'string') { options = { filename: options }; - } - if (typeof options !== 'object' || options === null) { + } else if (typeof options !== 'object' || options === null) { throw new ERR_INVALID_ARG_TYPE('options', 'Object', options); }