Skip to content

Commit 10b88cb

Browse files
zhangwinningcodebytere
authored andcommitted
dns: use ternary operator simplify statement
PR-URL: #33234 Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent 032c64f commit 10b88cb

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

lib/internal/dns/promises.js

+2-10
Original file line numberDiff line numberDiff line change
@@ -67,23 +67,15 @@ function createLookupPromise(family, hostname, all, hints, verbatim) {
6767
return new Promise((resolve, reject) => {
6868
if (!hostname) {
6969
emitInvalidHostnameWarning(hostname);
70-
if (all)
71-
resolve([]);
72-
else
73-
resolve({ address: null, family: family === 6 ? 6 : 4 });
74-
70+
resolve(all ? [] : { address: null, family: family === 6 ? 6 : 4 });
7571
return;
7672
}
7773

7874
const matchedFamily = isIP(hostname);
7975

8076
if (matchedFamily !== 0) {
8177
const result = { address: hostname, family: matchedFamily };
82-
if (all)
83-
resolve([result]);
84-
else
85-
resolve(result);
86-
78+
resolve(all ? [result] : result);
8779
return;
8880
}
8981

0 commit comments

Comments
 (0)