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
0 commit comments