diff options
author | Wenning Zhang <1527841714@qq.com> | 2020-05-04 18:40:30 +0300 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2020-05-23 22:38:44 +0300 |
commit | 5d06a374ea0f8b8d75dc70ba8e765847818dd15b (patch) | |
tree | b073a143cafe3607c6288d078d966935e891db87 /lib/internal/dns | |
parent | 9be51ee9a1ea8f9cc578abc1b9e70b220f7488ac (diff) |
dns: use ternary operator simplify statement
PR-URL: https://github.com/nodejs/node/pull/33234
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'lib/internal/dns')
-rw-r--r-- | lib/internal/dns/promises.js | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/lib/internal/dns/promises.js b/lib/internal/dns/promises.js index 6ade8854964..e5adc5b0485 100644 --- a/lib/internal/dns/promises.js +++ b/lib/internal/dns/promises.js @@ -67,11 +67,7 @@ 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; } @@ -79,11 +75,7 @@ function createLookupPromise(family, hostname, all, hints, verbatim) { if (matchedFamily !== 0) { const result = { address: hostname, family: matchedFamily }; - if (all) - resolve([result]); - else - resolve(result); - + resolve(all ? [result] : result); return; } |