Skip to content

Commit

Permalink
dns: use ternary operator simplify statement
Browse files Browse the repository at this point in the history
PR-URL: #33234
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
zhangwinning authored and codebytere committed Jul 8, 2020
1 parent 032c64f commit 10b88cb
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions lib/internal/dns/promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,15 @@ 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;
}

const matchedFamily = isIP(hostname);

if (matchedFamily !== 0) {
const result = { address: hostname, family: matchedFamily };
if (all)
resolve([result]);
else
resolve(result);

resolve(all ? [result] : result);
return;
}

Expand Down

0 comments on commit 10b88cb

Please sign in to comment.