diff options
author | cjihrig <cjihrig@gmail.com> | 2018-12-02 12:25:39 -0500 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2018-12-04 11:32:45 -0800 |
commit | 54f8453ea1211e1a11280e337ffdfdb7bc8f4ff1 (patch) | |
tree | 9480a55a5546c1fff62fe4578e7c95c03fcb4337 /lib | |
parent | 7ac939e106bf8d878f6e193bfef317f9bd237551 (diff) | |
download | android-node-v8-54f8453ea1211e1a11280e337ffdfdb7bc8f4ff1.tar.gz android-node-v8-54f8453ea1211e1a11280e337ffdfdb7bc8f4ff1.tar.bz2 android-node-v8-54f8453ea1211e1a11280e337ffdfdb7bc8f4ff1.zip |
dns: simplify dns.promises warning logic
dns.promises is lazy loaded. Instead of using a seaparate
Boolean flag to track whether or not it has been loaded, just
inspect the state of the lazy loaded module itself.
PR-URL: https://github.com/nodejs/node/pull/24788
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Weijia Wang <starkwang@126.com>
Reviewed-By: Masashi Hirano <shisama07@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/dns.js | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/dns.js b/lib/dns.js index ac3f6d6f0e..f68409f2ee 100644 --- a/lib/dns.js +++ b/lib/dns.js @@ -50,8 +50,7 @@ const { const dnsException = errors.dnsException; -let promisesWarn = true; -let promises; // Lazy loaded +let promises = null; // Lazy loaded function onlookup(err, addresses) { if (err) { @@ -269,7 +268,7 @@ function defaultResolverSetServers(servers) { setDefaultResolver(resolver); bindDefaultResolver(module.exports, Resolver.prototype); - if (promises !== undefined) + if (promises !== null) bindDefaultResolver(promises, promises.Resolver.prototype); } @@ -318,10 +317,9 @@ Object.defineProperties(module.exports, { configurable: true, enumerable: false, get() { - if (promisesWarn) { + if (promises === null) { promises = require('internal/dns/promises'); promises.setServers = defaultResolverSetServers; - promisesWarn = false; process.emitWarning('The dns.promises API is experimental', 'ExperimentalWarning'); } |