From 10b88cb11760abcd967da363d0d7787dc3ee35bd Mon Sep 17 00:00:00 2001 From: Wenning Zhang <1527841714@qq.com> Date: Mon, 4 May 2020 23:40:30 +0800 Subject: [PATCH] dns: use ternary operator simplify statement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/33234 Reviewed-By: Tobias Nießen Reviewed-By: Ruben Bridgewater --- lib/internal/dns/promises.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/lib/internal/dns/promises.js b/lib/internal/dns/promises.js index 6ade8854964c2e..e5adc5b048515f 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; }