vm: simplify Script constructor options validation

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 <targos@protonmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
cjihrig 2018-12-14 22:12:37 -05:00 committed by Rich Trott
parent 8dfd757337
commit 52ee55a06b

View File

@ -44,8 +44,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);
}