@@ -4,7 +4,7 @@ const assert = require('assert');
4
4
5
5
const dns = require ( 'dns' ) ;
6
6
7
- var existing = dns . getServers ( ) ;
7
+ const existing = dns . getServers ( ) ;
8
8
assert ( existing . length ) ;
9
9
10
10
// Verify that setServers() handles arrays with holes and other oddities
@@ -36,86 +36,71 @@ assert.doesNotThrow(() => {
36
36
37
37
function noop ( ) { }
38
38
39
- var goog = [
39
+ const goog = [
40
40
'8.8.8.8' ,
41
41
'8.8.4.4' ,
42
42
] ;
43
- assert . doesNotThrow ( function ( ) { dns . setServers ( goog ) ; } ) ;
43
+ assert . doesNotThrow ( ( ) => dns . setServers ( goog ) ) ;
44
44
assert . deepStrictEqual ( dns . getServers ( ) , goog ) ;
45
- assert . throws ( function ( ) { dns . setServers ( [ 'foobar' ] ) ; } ) ;
45
+ assert . throws ( ( ) => dns . setServers ( [ 'foobar' ] ) ) ;
46
46
assert . deepStrictEqual ( dns . getServers ( ) , goog ) ;
47
47
48
- var goog6 = [
48
+ const goog6 = [
49
49
'2001:4860:4860::8888' ,
50
50
'2001:4860:4860::8844' ,
51
51
] ;
52
- assert . doesNotThrow ( function ( ) { dns . setServers ( goog6 ) ; } ) ;
52
+ assert . doesNotThrow ( ( ) => dns . setServers ( goog6 ) ) ;
53
53
assert . deepStrictEqual ( dns . getServers ( ) , goog6 ) ;
54
54
55
55
goog6 . push ( '4.4.4.4' ) ;
56
56
dns . setServers ( goog6 ) ;
57
57
assert . deepStrictEqual ( dns . getServers ( ) , goog6 ) ;
58
58
59
- var ports = [
59
+ const ports = [
60
60
'4.4.4.4:53' ,
61
61
'[2001:4860:4860::8888]:53' ,
62
62
] ;
63
- var portsExpected = [
63
+ const portsExpected = [
64
64
'4.4.4.4' ,
65
65
'2001:4860:4860::8888' ,
66
66
] ;
67
67
dns . setServers ( ports ) ;
68
68
assert . deepStrictEqual ( dns . getServers ( ) , portsExpected ) ;
69
69
70
- assert . doesNotThrow ( function ( ) { dns . setServers ( [ ] ) ; } ) ;
70
+ assert . doesNotThrow ( ( ) => dns . setServers ( [ ] ) ) ;
71
71
assert . deepStrictEqual ( dns . getServers ( ) , [ ] ) ;
72
72
73
- assert . throws ( function ( ) {
73
+ assert . throws ( ( ) => {
74
74
dns . resolve ( 'test.com' , [ ] , noop ) ;
75
75
} , function ( err ) {
76
76
return ! ( err instanceof TypeError ) ;
77
77
} , 'Unexpected error' ) ;
78
78
79
79
// dns.lookup should accept falsey and string values
80
- assert . throws ( function ( ) {
81
- dns . lookup ( { } , noop ) ;
82
- } , 'invalid arguments: hostname must be a string or falsey' ) ;
80
+ assert . throws ( ( ) => dns . lookup ( { } , noop ) ,
81
+ 'invalid arguments: hostname must be a string or falsey' ) ;
83
82
84
- assert . throws ( function ( ) {
85
- dns . lookup ( [ ] , noop ) ;
86
- } , 'invalid arguments: hostname must be a string or falsey' ) ;
83
+ assert . throws ( ( ) => dns . lookup ( [ ] , noop ) ,
84
+ 'invalid arguments: hostname must be a string or falsey' ) ;
87
85
88
- assert . throws ( function ( ) {
89
- dns . lookup ( true , noop ) ;
90
- } , 'invalid arguments: hostname must be a string or falsey' ) ;
86
+ assert . throws ( ( ) => dns . lookup ( true , noop ) ,
87
+ 'invalid arguments: hostname must be a string or falsey' ) ;
91
88
92
- assert . throws ( function ( ) {
93
- dns . lookup ( 1 , noop ) ;
94
- } , 'invalid arguments: hostname must be a string or falsey' ) ;
89
+ assert . throws ( ( ) => dns . lookup ( 1 , noop ) ,
90
+ 'invalid arguments: hostname must be a string or falsey' ) ;
95
91
96
- assert . throws ( function ( ) {
97
- dns . lookup ( noop , noop ) ;
98
- } , 'invalid arguments: hostname must be a string or falsey' ) ;
92
+ assert . throws ( ( ) => dns . lookup ( noop , noop ) ,
93
+ 'invalid arguments: hostname must be a string or falsey' ) ;
99
94
100
- assert . doesNotThrow ( function ( ) {
101
- dns . lookup ( '' , noop ) ;
102
- } ) ;
95
+ assert . doesNotThrow ( ( ) => dns . lookup ( '' , noop ) ) ;
103
96
104
- assert . doesNotThrow ( function ( ) {
105
- dns . lookup ( null , noop ) ;
106
- } ) ;
97
+ assert . doesNotThrow ( ( ) => dns . lookup ( null , noop ) ) ;
107
98
108
- assert . doesNotThrow ( function ( ) {
109
- dns . lookup ( undefined , noop ) ;
110
- } ) ;
99
+ assert . doesNotThrow ( ( ) => dns . lookup ( undefined , noop ) ) ;
111
100
112
- assert . doesNotThrow ( function ( ) {
113
- dns . lookup ( 0 , noop ) ;
114
- } ) ;
101
+ assert . doesNotThrow ( ( ) => dns . lookup ( 0 , noop ) ) ;
115
102
116
- assert . doesNotThrow ( function ( ) {
117
- dns . lookup ( NaN , noop ) ;
118
- } ) ;
103
+ assert . doesNotThrow ( ( ) => dns . lookup ( NaN , noop ) ) ;
119
104
120
105
/*
121
106
* Make sure that dns.lookup throws if hints does not represent a valid flag.
@@ -126,85 +111,58 @@ assert.doesNotThrow(function() {
126
111
* - it's an odd number different than 1, and thus is invalid, because
127
112
* flags are either === 1 or even.
128
113
*/
129
- assert . throws ( function ( ) {
114
+ assert . throws ( ( ) => {
130
115
dns . lookup ( 'www.google.com' , { hints : ( dns . V4MAPPED | dns . ADDRCONFIG ) + 1 } ,
131
116
noop ) ;
132
117
} ) ;
133
118
134
- assert . throws ( function ( ) {
135
- dns . lookup ( 'www.google.com' ) ;
136
- } , 'invalid arguments: callback must be passed' ) ;
119
+ assert . throws ( ( ) => dns . lookup ( 'www.google.com' ) ,
120
+ 'invalid arguments: callback must be passed' ) ;
137
121
138
- assert . throws ( function ( ) {
139
- dns . lookup ( 'www.google.com' , 4 ) ;
140
- } , 'invalid arguments: callback must be passed' ) ;
122
+ assert . throws ( ( ) => dns . lookup ( 'www.google.com' , 4 ) ,
123
+ 'invalid arguments: callback must be passed' ) ;
141
124
142
- assert . doesNotThrow ( function ( ) {
143
- dns . lookup ( 'www.google.com' , 6 , noop ) ;
144
- } ) ;
125
+ assert . doesNotThrow ( ( ) => dns . lookup ( 'www.google.com' , 6 , noop ) ) ;
145
126
146
- assert . doesNotThrow ( function ( ) {
147
- dns . lookup ( 'www.google.com' , { } , noop ) ;
148
- } ) ;
127
+ assert . doesNotThrow ( ( ) => dns . lookup ( 'www.google.com' , { } , noop ) ) ;
149
128
150
- assert . doesNotThrow ( function ( ) {
151
- dns . lookup ( '' , {
152
- family : 4 ,
153
- hints : 0
154
- } , noop ) ;
155
- } ) ;
129
+ assert . doesNotThrow ( ( ) => dns . lookup ( '' , { family : 4 , hints : 0 } , noop ) ) ;
156
130
157
- assert . doesNotThrow ( function ( ) {
131
+ assert . doesNotThrow ( ( ) => {
158
132
dns . lookup ( '' , {
159
133
family : 6 ,
160
134
hints : dns . ADDRCONFIG
161
135
} , noop ) ;
162
136
} ) ;
163
137
164
- assert . doesNotThrow ( function ( ) {
165
- dns . lookup ( '' , {
166
- hints : dns . V4MAPPED
167
- } , noop ) ;
168
- } ) ;
138
+ assert . doesNotThrow ( ( ) => dns . lookup ( '' , { hints : dns . V4MAPPED } , noop ) ) ;
169
139
170
- assert . doesNotThrow ( function ( ) {
140
+ assert . doesNotThrow ( ( ) => {
171
141
dns . lookup ( '' , {
172
142
hints : dns . ADDRCONFIG | dns . V4MAPPED
173
143
} , noop ) ;
174
144
} ) ;
175
145
176
- assert . throws ( function ( ) {
177
- dns . lookupService ( '0.0.0.0' ) ;
178
- } , / I n v a l i d a r g u m e n t s / ) ;
146
+ assert . throws ( ( ) => dns . lookupService ( '0.0.0.0' ) , / I n v a l i d a r g u m e n t s / ) ;
179
147
180
- assert . throws ( function ( ) {
181
- dns . lookupService ( 'fasdfdsaf' , 0 , noop ) ;
182
- } , / " h o s t " a r g u m e n t n e e d s t o b e a v a l i d I P a d d r e s s / ) ;
148
+ assert . throws ( ( ) => dns . lookupService ( 'fasdfdsaf' , 0 , noop ) ,
149
+ / " h o s t " a r g u m e n t n e e d s t o b e a v a l i d I P a d d r e s s / ) ;
183
150
184
- assert . doesNotThrow ( function ( ) {
185
- dns . lookupService ( '0.0.0.0' , '0' , noop ) ;
186
- } ) ;
151
+ assert . doesNotThrow ( ( ) => dns . lookupService ( '0.0.0.0' , '0' , noop ) ) ;
187
152
188
- assert . doesNotThrow ( function ( ) {
189
- dns . lookupService ( '0.0.0.0' , 0 , noop ) ;
190
- } ) ;
153
+ assert . doesNotThrow ( ( ) => dns . lookupService ( '0.0.0.0' , 0 , noop ) ) ;
191
154
192
- assert . throws ( function ( ) {
193
- dns . lookupService ( '0.0.0.0' , null , noop ) ;
194
- } , / " p o r t " s h o u l d b e > = 0 a n d < 6 5 5 3 6 , g o t " n u l l " / ) ;
155
+ assert . throws ( ( ) => dns . lookupService ( '0.0.0.0' , null , noop ) ,
156
+ / " p o r t " s h o u l d b e > = 0 a n d < 6 5 5 3 6 , g o t " n u l l " / ) ;
195
157
196
- assert . throws ( function ( ) {
197
- dns . lookupService ( '0.0.0.0' , undefined , noop ) ;
198
- } , / " p o r t " s h o u l d b e > = 0 a n d < 6 5 5 3 6 , g o t " u n d e f i n e d " / ) ;
158
+ assert . throws ( ( ) => dns . lookupService ( '0.0.0.0' , undefined , noop ) ,
159
+ / " p o r t " s h o u l d b e > = 0 a n d < 6 5 5 3 6 , g o t " u n d e f i n e d " / ) ;
199
160
200
- assert . throws ( function ( ) {
201
- dns . lookupService ( '0.0.0.0' , 65538 , noop ) ;
202
- } , / " p o r t " s h o u l d b e > = 0 a n d < 6 5 5 3 6 , g o t " 6 5 5 3 8 " / ) ;
161
+ assert . throws ( ( ) => dns . lookupService ( '0.0.0.0' , 65538 , noop ) ,
162
+ / " p o r t " s h o u l d b e > = 0 a n d < 6 5 5 3 6 , g o t " 6 5 5 3 8 " / ) ;
203
163
204
- assert . throws ( function ( ) {
205
- dns . lookupService ( '0.0.0.0' , 'test' , noop ) ;
206
- } , / " p o r t " s h o u l d b e > = 0 a n d < 6 5 5 3 6 , g o t " t e s t " / ) ;
164
+ assert . throws ( ( ) => dns . lookupService ( '0.0.0.0' , 'test' , noop ) ,
165
+ / " p o r t " s h o u l d b e > = 0 a n d < 6 5 5 3 6 , g o t " t e s t " / ) ;
207
166
208
- assert . throws ( ( ) => {
209
- dns . lookupService ( '0.0.0.0' , 80 , null ) ;
210
- } , / ^ T y p e E r r o r : " c a l l b a c k " a r g u m e n t m u s t b e a f u n c t i o n $ / ) ;
167
+ assert . throws ( ( ) => dns . lookupService ( '0.0.0.0' , 80 , null ) ,
168
+ / ^ T y p e E r r o r : " c a l l b a c k " a r g u m e n t m u s t b e a f u n c t i o n $ / ) ;
0 commit comments