| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,9 +22,11 @@ | |||
| 22 | 22 | 'use strict'; | |
| 23 | 23 | ||
| 24 | 24 | const { | |
| 25 | + ArrayPrototypeMap, | ||
| 25 | 26 | ObjectCreate, | |
| 26 | 27 | ObjectDefineProperties, | |
| 27 | 28 | ObjectDefineProperty, | |
| 29 | + ReflectApply, | ||
| 28 | 30 | } = primordials; | |
| 29 | 31 | ||
| 30 | 32 | const cares = internalBinding('cares_wrap'); | |
@@ -197,7 +199,8 @@ ObjectDefineProperty(lookupService, customPromisifyArgs, | |||
| 197 | 199 | ||
| 198 | 200 | function onresolve(err, result, ttls) { | |
| 199 | 201 | if (ttls && this.ttl) | |
| 200 | - result = result.map((address, index) => ({ address, ttl: ttls[index] })); | ||
| 202 | + result = ArrayPrototypeMap( | ||
| 203 | + result, (address, index) => ({ address, ttl: ttls[index] })); | ||
| 201 | 204 | ||
| 202 | 205 | if (err) | |
| 203 | 206 | this.callback(dnsException(err, this.bindingName, this.hostname)); | |
@@ -261,7 +264,7 @@ function resolve(hostname, rrtype, callback) { | |||
| 261 | 264 | } | |
| 262 | 265 | ||
| 263 | 266 | if (typeof resolver === 'function') { | |
| 264 | - return resolver.call(this, hostname, callback); | ||
| 267 | + return ReflectApply(resolver, this, [hostname, callback]); | ||
| 265 | 268 | } | |
| 266 | 269 | throw new ERR_INVALID_ARG_VALUE('rrtype', rrtype); | |
| 267 | 270 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,9 +1,11 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | ||
| 3 | 3 | const { | |
| 4 | + ArrayPrototypeMap, | ||
| 4 | 5 | ObjectCreate, | |
| 5 | 6 | ObjectDefineProperty, | |
| 6 | 7 | Promise, | |
| 8 | + ReflectApply, | ||
| 7 | 9 | } = primordials; | |
| 8 | 10 | ||
| 9 | 11 | const { | |
@@ -169,7 +171,8 @@ function onresolve(err, result, ttls) { | |||
| 169 | 171 | } | |
| 170 | 172 | ||
| 171 | 173 | if (ttls && this.ttl) | |
| 172 | - result = result.map((address, index) => ({ address, ttl: ttls[index] })); | ||
| 174 | + result = ArrayPrototypeMap( | ||
| 175 | + result, (address, index) => ({ address, ttl: ttls[index] })); | ||
| 173 | 176 | ||
| 174 | 177 | this.resolve(result); | |
| 175 | 178 | } | |
@@ -246,7 +249,7 @@ Resolver.prototype.resolve = function resolve(hostname, rrtype) { | |||
| 246 | 249 | throw new ERR_INVALID_ARG_TYPE('rrtype', 'string', rrtype); | |
| 247 | 250 | } | |
| 248 | 251 | ||
| 249 | - return resolver.call(this, hostname); | ||
| 252 | + return ReflectApply(resolver, this, [hostname]); | ||
| 250 | 253 | }; | |
| 251 | 254 | ||
| 252 | 255 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,8 +2,13 @@ | |||
| 2 | 2 | ||
| 3 | 3 | const { | |
| 4 | 4 | ArrayIsArray, | |
| 5 | + ArrayPrototypeForEach, | ||
| 6 | + ArrayPrototypeJoin, | ||
| 7 | + ArrayPrototypeMap, | ||
| 5 | 8 | ArrayPrototypePush, | |
| 9 | + FunctionPrototypeBind, | ||
| 6 | 10 | NumberParseInt, | |
| 11 | + StringPrototypeMatch, | ||
| 7 | 12 | StringPrototypeReplace, | |
| 8 | 13 | } = primordials; | |
| 9 | 14 | ||
@@ -45,7 +50,7 @@ class Resolver { | |||
| 45 | 50 | } | |
| 46 | 51 | ||
| 47 | 52 | getServers() { | |
| 48 | - return this._handle.getServers().map((val) => { | ||
| 53 | + return ArrayPrototypeMap(this._handle.getServers(), (val) => { | ||
| 49 | 54 | if (!val[1] || val[1] === IANA_DNS_PORT) | |
| 50 | 55 | return val[0]; | |
| 51 | 56 | ||
@@ -65,16 +70,16 @@ class Resolver { | |||
| 65 | 70 | const orig = this._handle.getServers(); | |
| 66 | 71 | const newSet = []; | |
| 67 | 72 | ||
| 68 | - servers.forEach((serv, index) => { | ||
| 73 | + ArrayPrototypeForEach(servers, (serv, index) => { | ||
| 69 | 74 | if (typeof serv !== 'string') { | |
| 70 | 75 | throw new ERR_INVALID_ARG_TYPE(`servers[${index}]`, 'string', serv); | |
| 71 | 76 | } | |
| 72 | 77 | let ipVersion = isIP(serv); | |
| 73 | 78 | ||
| 74 | 79 | if (ipVersion !== 0) | |
| 75 | - return newSet.push([ipVersion, serv, IANA_DNS_PORT]); | ||
| 80 | + return ArrayPrototypePush(newSet, [ipVersion, serv, IANA_DNS_PORT]); | ||
| 76 | 81 | ||
| 77 | - const match = serv.match(IPv6RE); | ||
| 82 | + const match = StringPrototypeMatch(serv, IPv6RE); | ||
| 78 | 83 | ||
| 79 | 84 | // Check for an IPv6 in brackets. | |
| 80 | 85 | if (match) { | |
@@ -88,7 +93,7 @@ class Resolver { | |||
| 88 | 93 | } | |
| 89 | 94 | ||
| 90 | 95 | // addr::port | |
| 91 | - const addrSplitMatch = serv.match(addrSplitRE); | ||
| 96 | + const addrSplitMatch = StringPrototypeMatch(serv, addrSplitRE); | ||
| 92 | 97 | ||
| 93 | 98 | if (addrSplitMatch) { | |
| 94 | 99 | const hostIP = addrSplitMatch[1]; | |
@@ -109,7 +114,7 @@ class Resolver { | |||
| 109 | 114 | ||
| 110 | 115 | if (errorNumber !== 0) { | |
| 111 | 116 | // Reset the servers to the old servers, because ares probably unset them. | |
| 112 | - this._handle.setServers(orig.join(',')); | ||
| 117 | + this._handle.setServers(ArrayPrototypeJoin(orig, ',')); | ||
| 113 | 118 | const err = strerror(errorNumber); | |
| 114 | 119 | throw new ERR_DNS_SET_SERVERS_FAILED(err, servers); | |
| 115 | 120 | } | |
@@ -156,8 +161,8 @@ function setDefaultResolver(resolver) { | |||
| 156 | 161 | } | |
| 157 | 162 | ||
| 158 | 163 | function bindDefaultResolver(target, source) { | |
| 159 | - resolverKeys.forEach((key) => { | ||
| 160 | - target[key] = source[key].bind(defaultResolver); | ||
| 164 | + ArrayPrototypeForEach(resolverKeys, (key) => { | ||
| 165 | + target[key] = FunctionPrototypeBind(source[key], defaultResolver); | ||
| 161 | 166 | }); | |
| 162 | 167 | } | |
| 163 | 168 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments