Skip to content

Commit

Permalink
module, esm: jsdoc for modules files
Browse files Browse the repository at this point in the history
PR-URL: #49523
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
  • Loading branch information
GeoffreyBooth authored and targos committed Nov 11, 2023
1 parent 5dfe423 commit 142ac3f
Show file tree
Hide file tree
Showing 13 changed files with 711 additions and 158 deletions.
24 changes: 24 additions & 0 deletions lib/internal/dns/promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,19 @@ function onlookupall(err, addresses) {
}
}

/**
* Creates a promise that resolves with the IP address of the given hostname.
* @param {0 | 4 | 6} family - The IP address family (4 or 6, or 0 for both).
* @param {string} hostname - The hostname to resolve.
* @param {boolean} all - Whether to resolve with all IP addresses for the hostname.
* @param {number} hints - One or more supported getaddrinfo flags (supply multiple via
* bitwise OR).
* @param {boolean} verbatim - Whether to use the hostname verbatim.
* @returns {Promise<DNSLookupResult | DNSLookupResult[]>} The IP address(es) of the hostname.
* @typedef {object} DNSLookupResult
* @property {string} address - The IP address.
* @property {0 | 4 | 6} family - The IP address type. 4 for IPv4 or 6 for IPv6, or 0 (for both).
*/
function createLookupPromise(family, hostname, all, hints, verbatim) {
return new Promise((resolve, reject) => {
if (!hostname) {
Expand Down Expand Up @@ -154,6 +167,17 @@ function createLookupPromise(family, hostname, all, hints, verbatim) {
}

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

0 comments on commit 142ac3f

Please sign in to comment.