@@ -113,6 +113,19 @@ function onlookupall(err, addresses) {
113
113
}
114
114
}
115
115
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
+ */
116
129
function createLookupPromise ( family , hostname , all , hints , verbatim ) {
117
130
return new Promise ( ( resolve , reject ) => {
118
131
if ( ! hostname ) {
@@ -154,6 +167,17 @@ function createLookupPromise(family, hostname, all, hints, verbatim) {
154
167
}
155
168
156
169
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
+ */
157
181
function lookup ( hostname , options ) {
158
182
let hints = 0 ;
159
183
let family = 0 ;
0 commit comments