22
33const {
44 ArrayIsArray,
5+ ArrayPrototypeForEach,
6+ ArrayPrototypeJoin,
7+ ArrayPrototypeMap,
58 ArrayPrototypePush,
9+ FunctionPrototypeBind,
610 NumberParseInt,
11+ StringPrototypeMatch,
712 StringPrototypeReplace,
813} = primordials ;
914
@@ -45,7 +50,7 @@ class Resolver {
4550 }
4651
4752 getServers ( ) {
48- return this . _handle . getServers ( ) . map ( ( val ) => {
53+ return ArrayPrototypeMap ( this . _handle . getServers ( ) , ( val ) => {
4954 if ( ! val [ 1 ] || val [ 1 ] === IANA_DNS_PORT )
5055 return val [ 0 ] ;
5156
@@ -65,16 +70,16 @@ class Resolver {
6570 const orig = this . _handle . getServers ( ) ;
6671 const newSet = [ ] ;
6772
68- servers . forEach ( ( serv , index ) => {
73+ ArrayPrototypeForEach ( servers , ( serv , index ) => {
6974 if ( typeof serv !== 'string' ) {
7075 throw new ERR_INVALID_ARG_TYPE ( `servers[${ index } ]` , 'string' , serv ) ;
7176 }
7277 let ipVersion = isIP ( serv ) ;
7378
7479 if ( ipVersion !== 0 )
75- return newSet . push ( [ ipVersion , serv , IANA_DNS_PORT ] ) ;
80+ return ArrayPrototypePush ( newSet , [ ipVersion , serv , IANA_DNS_PORT ] ) ;
7681
77- const match = serv . match ( IPv6RE ) ;
82+ const match = StringPrototypeMatch ( serv , IPv6RE ) ;
7883
7984 // Check for an IPv6 in brackets.
8085 if ( match ) {
@@ -88,7 +93,7 @@ class Resolver {
8893 }
8994
9095 // addr::port
91- const addrSplitMatch = serv . match ( addrSplitRE ) ;
96+ const addrSplitMatch = StringPrototypeMatch ( serv , addrSplitRE ) ;
9297
9398 if ( addrSplitMatch ) {
9499 const hostIP = addrSplitMatch [ 1 ] ;
@@ -109,7 +114,7 @@ class Resolver {
109114
110115 if ( errorNumber !== 0 ) {
111116 // Reset the servers to the old servers, because ares probably unset them.
112- this . _handle . setServers ( orig . join ( ',' ) ) ;
117+ this . _handle . setServers ( ArrayPrototypeJoin ( orig , ',' ) ) ;
113118 const err = strerror ( errorNumber ) ;
114119 throw new ERR_DNS_SET_SERVERS_FAILED ( err , servers ) ;
115120 }
@@ -156,8 +161,8 @@ function setDefaultResolver(resolver) {
156161}
157162
158163function 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 ) ;
161166 } ) ;
162167}
163168
0 commit comments