Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
dns: use ternary operator simplify statement
  • Loading branch information
zhangwinning committed May 4, 2020
commit 5bf6d117a638be7ef70edf8f9d76929189f1301d
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