dns: use ternary operator simplify statement

PR-URL: https://github.com/nodejs/node/pull/33234
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
Wenning Zhang authored and Shelley Vohr committed 2020-07-08 11:15:05 -07:00
1 parent 032c64f1e4
commit 10b88cb117
1 file changed
+2 -10
+2 -10
View File
@@ -67,11 +67,7 @@ function createLookupPromise(family, hostname, all, hints, verbatim) {
return new Promise((resolve, reject) => {
if (!hostname) {
emitInvalidHostnameWarning(hostname);
if (all)
resolve([]);
else
resolve({ address: null, family: family === 6 ? 6 : 4 });
resolve(all ? [] : { address: null, family: family === 6 ? 6 : 4 });
return;
}
@@ -79,11 +75,7 @@ function createLookupPromise(family, hostname, all, hints, verbatim) {
if (matchedFamily !== 0) {
const result = { address: hostname, family: matchedFamily };
if (all)
resolve([result]);
else
resolve(result);
resolve(all ? [result] : result);
return;
}