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 codebytere committed Jun 18, 2020
1 parent b794959 commit eb55d9e
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 eb55d9e

Please sign in to comment.