Skip to content

Commit 142ac3f

Browse files
GeoffreyBoothtargos
authored andcommitted
module, esm: jsdoc for modules files
PR-URL: #49523 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]>
1 parent 5dfe423 commit 142ac3f

13 files changed

+711
-158
lines changed

lib/internal/dns/promises.js

+24
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,19 @@ function onlookupall(err, addresses) {
113113
}
114114
}
115115

116+
/**
117+
* Creates a promise that resolves with the IP address of the given hostname.
118+
* @param {0 | 4 | 6} family - The IP address family (4 or 6, or 0 for both).
119+
* @param {string} hostname - The hostname to resolve.
120+
* @param {boolean} all - Whether to resolve with all IP addresses for the hostname.
121+
* @param {number} hints - One or more supported getaddrinfo flags (supply multiple via
122+
* bitwise OR).
123+
* @param {boolean} verbatim - Whether to use the hostname verbatim.
124+
* @returns {Promise<DNSLookupResult | DNSLookupResult[]>} The IP address(es) of the hostname.
125+
* @typedef {object} DNSLookupResult
126+
* @property {string} address - The IP address.
127+
* @property {0 | 4 | 6} family - The IP address type. 4 for IPv4 or 6 for IPv6, or 0 (for both).
128+
*/
116129
function createLookupPromise(family, hostname, all, hints, verbatim) {
117130
return new Promise((resolve, reject) => {
118131
if (!hostname) {
@@ -154,6 +167,17 @@ function createLookupPromise(family, hostname, all, hints, verbatim) {
154167
}
155168

156169
const validFamilies = [0, 4, 6];
170+
/**
171+
* Get the IP address for a given hostname.
172+
* @param {string} hostname - The hostname to resolve (ex. 'nodejs.org').
173+
* @param {object} [options] - Optional settings.
174+
* @param {boolean} [options.all=false] - Whether to return all or just the first resolved address.
175+
* @param {0 | 4 | 6} [options.family=0] - The record family. Must be 4, 6, or 0 (for both).
176+
* @param {number} [options.hints] - One or more supported getaddrinfo flags (supply multiple via
177+
* bitwise OR).
178+
* @param {boolean} [options.verbatim=false] - Return results in same order DNS resolved them;
179+
* otherwise IPv4 then IPv6. New code should supply `true`.
180+
*/
157181
function lookup(hostname, options) {
158182
let hints = 0;
159183
let family = 0;

0 commit comments

Comments
 (0)