From faf6654ff75e0f275afddfd980387235c3ddf103 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sun, 16 Apr 2017 21:35:29 +0200 Subject: [PATCH] dns: support promisified `lookup(Service)` PR-URL: https://github.com/nodejs/node/pull/12442 Reviewed-By: Benjamin Gruenbaum Reviewed-By: Matteo Collina Reviewed-By: James M Snell Reviewed-By: Myles Borins Reviewed-By: Evan Lucas Reviewed-By: William Kapke Reviewed-By: Timothy Gu Reviewed-By: Teddy Katz --- doc/api/dns.md | 8 ++++++++ lib/dns.js | 7 +++++++ test/internet/test-dns-ipv4.js | 13 +++++++++++++ test/internet/test-dns.js | 28 ++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+) diff --git a/doc/api/dns.md b/doc/api/dns.md index 0cacd5b402..42d93a14e7 100644 --- a/doc/api/dns.md +++ b/doc/api/dns.md @@ -123,6 +123,10 @@ dns.lookup('example.com', options, (err, addresses) => // addresses: [{"address":"2606:2800:220:1:248:1893:25c8:1946","family":6}] ``` +If this method is invoked as its [`util.promisify()`][]ed version, and `all` +is not set to `true`, it returns a Promise for an object with `address` and +`family` properties. + ### Supported getaddrinfo flags The following flags can be passed as hints to [`dns.lookup()`][]. @@ -163,6 +167,9 @@ dns.lookupService('127.0.0.1', 22, (err, hostname, service) => { }); ``` +If this method is invoked as its [`util.promisify()`][]ed version, it returns a +Promise for an object with `hostname` and `service` properties. + ## dns.resolve(hostname[, rrtype], callback)