@@ -29,7 +29,6 @@ const { |
29 | 29 | QueryReqWrap |
30 | 30 | } = internalBinding('cares_wrap'); |
31 | 31 | const { |
32 | | - ERR_INVALID_ARG_TYPE, |
33 | 32 | ERR_INVALID_ARG_VALUE, |
34 | 33 | ERR_MISSING_ARGS, |
35 | 34 | } = codes; |
@@ -45,7 +44,7 @@ function onlookup(err, addresses) { |
45 | 44 | return; |
46 | 45 | } |
47 | 46 |
|
48 | | - const family = this.family ? this.family : isIP(addresses[0]); |
| 47 | + const family = this.family || isIP(addresses[0]); |
49 | 48 | this.resolve({ address: addresses[0], family }); |
50 | 49 | } |
51 | 50 |
|
@@ -62,7 +61,7 @@ function onlookupall(err, addresses) { |
62 | 61 |
|
63 | 62 | addresses[i] = { |
64 | 63 | address, |
65 | | - family: family ? family : isIP(addresses[i]) |
| 64 | + family: family || isIP(addresses[i]) |
66 | 65 | }; |
67 | 66 | } |
68 | 67 |
|
@@ -108,9 +107,11 @@ function lookup(hostname, options) { |
108 | 107 | var verbatim = getDefaultVerbatim(); |
109 | 108 |
|
110 | 109 | // Parse arguments |
111 | | - if (hostname && typeof hostname !== 'string') { |
112 | | - throw new ERR_INVALID_ARG_TYPE('hostname', 'string', hostname); |
113 | | - } else if (options !== null && typeof options === 'object') { |
| 110 | + if (hostname) { |
| 111 | + validateString(hostname, 'hostname'); |
| 112 | + } |
| 113 | + |
| 114 | + if (options !== null && typeof options === 'object') { |
114 | 115 | if (options.hints != null && typeof options.hints !== 'number') { |
115 | 116 | emitTypeCoercionDeprecationWarning(); |
116 | 117 | } |
@@ -257,15 +258,15 @@ Resolver.prototype.reverse = resolver('getHostByAddr'); |
257 | 258 | Resolver.prototype.resolve = function resolve(hostname, rrtype) { |
258 | 259 | var resolver; |
259 | 260 |
|
260 | | - if (typeof rrtype === 'string') { |
| 261 | + if (rrtype !== undefined) { |
| 262 | + validateString(rrtype, 'rrtype'); |
| 263 | + |
261 | 264 | resolver = resolveMap[rrtype]; |
262 | 265 |
|
263 | 266 | if (typeof resolver !== 'function') |
264 | 267 | throw new ERR_INVALID_ARG_VALUE('rrtype', rrtype); |
265 | | - } else if (rrtype === undefined) { |
266 | | - resolver = resolveMap.A; |
267 | 268 | } else { |
268 | | - throw new ERR_INVALID_ARG_TYPE('rrtype', 'string', rrtype); |
| 269 | + resolver = resolveMap.A; |
269 | 270 | } |
270 | 271 |
|
271 | 272 | return ReflectApply(resolver, this, [hostname]); |
|