| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -28,7 +28,6 @@ const { | |||
| 28 | 28 | QueryReqWrap | |
| 29 | 29 | } = internalBinding('cares_wrap'); | |
| 30 | 30 | const { | |
| 31 | - ERR_INVALID_ARG_TYPE, | ||
| 32 | 31 | ERR_INVALID_ARG_VALUE, | |
| 33 | 32 | ERR_MISSING_ARGS, | |
| 34 | 33 | } = codes; | |
@@ -44,7 +43,7 @@ function onlookup(err, addresses) { | |||
| 44 | 43 | return; | |
| 45 | 44 | } | |
| 46 | 45 | ||
| 47 | - const family = this.family ? this.family : isIP(addresses[0]); | ||
| 46 | + const family = this.family || isIP(addresses[0]); | ||
| 48 | 47 | this.resolve({ address: addresses[0], family }); | |
| 49 | 48 | } | |
| 50 | 49 | ||
@@ -61,7 +60,7 @@ function onlookupall(err, addresses) { | |||
| 61 | 60 | ||
| 62 | 61 | addresses[i] = { | |
| 63 | 62 | address, | |
| 64 | - family: family ? family : isIP(addresses[i]) | ||
| 63 | + family: family || isIP(addresses[i]) | ||
| 65 | 64 | }; | |
| 66 | 65 | } | |
| 67 | 66 | ||
@@ -107,9 +106,11 @@ function lookup(hostname, options) { | |||
| 107 | 106 | var verbatim = getDefaultVerbatim(); | |
| 108 | 107 | ||
| 109 | 108 | // 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') { | ||
| 113 | 114 | hints = options.hints >>> 0; | |
| 114 | 115 | family = options.family >>> 0; | |
| 115 | 116 | all = options.all === true; | |
@@ -242,15 +243,15 @@ Resolver.prototype.reverse = resolver('getHostByAddr'); | |||
| 242 | 243 | Resolver.prototype.resolve = function resolve(hostname, rrtype) { | |
| 243 | 244 | var resolver; | |
| 244 | 245 | ||
| 245 | - if (typeof rrtype === 'string') { | ||
| 246 | + if (rrtype !== undefined) { | ||
| 247 | + validateString(rrtype, 'rrtype'); | ||
| 248 | + | ||
| 246 | 249 | resolver = resolveMap[rrtype]; | |
| 247 | 250 | ||
| 248 | 251 | if (typeof resolver !== 'function') | |
| 249 | 252 | throw new ERR_INVALID_ARG_VALUE('rrtype', rrtype); | |
| 250 | - } else if (rrtype === undefined) { | ||
| 251 | - resolver = resolveMap.A; | ||
| 252 | 253 | } else { | |
| 253 | - throw new ERR_INVALID_ARG_TYPE('rrtype', 'string', rrtype); | ||
| 254 | + resolver = resolveMap.A; | ||
| 254 | 255 | } | |
| 255 | 256 | ||
| 256 | 257 | return ReflectApply(resolver, this, [hostname]); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments