@@ -28,7 +28,6 @@ const {
2828 QueryReqWrap
2929} = internalBinding ( 'cares_wrap' ) ;
3030const {
31- ERR_INVALID_ARG_TYPE ,
3231 ERR_INVALID_ARG_VALUE ,
3332 ERR_MISSING_ARGS ,
3433} = codes ;
@@ -44,7 +43,7 @@ function onlookup(err, addresses) {
4443 return ;
4544 }
4645
47- const family = this . family ? this . family : isIP ( addresses [ 0 ] ) ;
46+ const family = this . family || isIP ( addresses [ 0 ] ) ;
4847 this . resolve ( { address : addresses [ 0 ] , family } ) ;
4948}
5049
@@ -61,7 +60,7 @@ function onlookupall(err, addresses) {
6160
6261 addresses [ i ] = {
6362 address,
64- family : family ? family : isIP ( addresses [ i ] )
63+ family : family || isIP ( addresses [ i ] )
6564 } ;
6665 }
6766
@@ -107,9 +106,11 @@ function lookup(hostname, options) {
107106 var verbatim = getDefaultVerbatim ( ) ;
108107
109108 // Parse arguments
110- if ( hostname && typeof hostname !== 'string' ) {
111- throw new ERR_INVALID_ARG_TYPE ( 'hostname' , 'string' , hostname ) ;
112- } else if ( options !== null && typeof options === 'object' ) {
109+ if ( hostname ) {
110+ validateString ( hostname , 'hostname' ) ;
111+ }
112+
113+ if ( options !== null && typeof options === 'object' ) {
113114 hints = options . hints >>> 0 ;
114115 family = options . family >>> 0 ;
115116 all = options . all === true ;
@@ -242,15 +243,15 @@ Resolver.prototype.reverse = resolver('getHostByAddr');
242243Resolver . prototype . resolve = function resolve ( hostname , rrtype ) {
243244 var resolver ;
244245
245- if ( typeof rrtype === 'string' ) {
246+ if ( rrtype !== undefined ) {
247+ validateString ( rrtype , 'rrtype' ) ;
248+
246249 resolver = resolveMap [ rrtype ] ;
247250
248251 if ( typeof resolver !== 'function' )
249252 throw new ERR_INVALID_ARG_VALUE ( 'rrtype' , rrtype ) ;
250- } else if ( rrtype === undefined ) {
251- resolver = resolveMap . A ;
252253 } else {
253- throw new ERR_INVALID_ARG_TYPE ( 'rrtype' , 'string' , rrtype ) ;
254+ resolver = resolveMap . A ;
254255 }
255256
256257 return ReflectApply ( resolver , this , [ hostname ] ) ;
0 commit comments