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 <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
  • Loading branch information
zhangwinning authored and BridgeAR committed May 23, 2020
1 parent 9be51ee commit 5d06a37
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 5d06a37

Please sign in to comment.