23
23
24
24
const {
25
25
ArrayIsArray,
26
+ ArrayPrototypeIndexOf,
27
+ ArrayPrototypePush,
28
+ ArrayPrototypeSplice,
26
29
Boolean,
27
30
Error,
31
+ FunctionPrototype,
32
+ FunctionPrototypeCall,
28
33
Number,
29
34
NumberIsNaN,
30
35
NumberParseInt,
31
36
ObjectDefineProperty,
32
37
ObjectSetPrototypeOf,
38
+ ReflectApply,
33
39
Symbol,
34
40
} = primordials ;
35
41
@@ -123,7 +129,7 @@ const DEFAULT_IPV6_ADDR = '::';
123
129
124
130
const isWindows = process . platform === 'win32' ;
125
131
126
- function noop ( ) { }
132
+ const noop = FunctionPrototype ;
127
133
128
134
function getFlags ( ipv6Only ) {
129
135
return ipv6Only === true ? TCPConstants . UV_TCP_IPV6ONLY : 0 ;
@@ -298,7 +304,7 @@ function Socket(options) {
298
304
options . autoDestroy = false ;
299
305
// Handle strings directly.
300
306
options . decodeStrings = false ;
301
- stream . Duplex . call ( this , options ) ;
307
+ ReflectApply ( stream . Duplex , this , [ options ] ) ;
302
308
303
309
// Default to *not* allowing half open sockets.
304
310
this . allowHalfOpen = Boolean ( allowHalfOpen ) ;
@@ -588,7 +594,7 @@ Socket.prototype._read = function(n) {
588
594
589
595
590
596
Socket . prototype . end = function ( data , encoding , callback ) {
591
- stream . Duplex . prototype . end . call ( this , data , encoding , callback ) ;
597
+ ReflectApply ( stream . Duplex . prototype . end , this , [ data , encoding , callback ] ) ;
592
598
DTRACE_NET_STREAM_END ( this ) ;
593
599
return this ;
594
600
} ;
@@ -604,7 +610,7 @@ Socket.prototype.pause = function() {
604
610
this . destroy ( errnoException ( err , 'read' ) ) ;
605
611
}
606
612
}
607
- return stream . Duplex . prototype . pause . call ( this ) ;
613
+ return FunctionPrototypeCall ( stream . Duplex . prototype . pause , this ) ;
608
614
} ;
609
615
610
616
@@ -613,7 +619,7 @@ Socket.prototype.resume = function() {
613
619
! this . _handle . reading ) {
614
620
tryReadStart ( this ) ;
615
621
}
616
- return stream . Duplex . prototype . resume . call ( this ) ;
622
+ return FunctionPrototypeCall ( stream . Duplex . prototype . resume , this ) ;
617
623
} ;
618
624
619
625
@@ -622,7 +628,7 @@ Socket.prototype.read = function(n) {
622
628
! this . _handle . reading ) {
623
629
tryReadStart ( this ) ;
624
630
}
625
- return stream . Duplex . prototype . read . call ( this , n ) ;
631
+ return ReflectApply ( stream . Duplex . prototype . read , this , [ n ] ) ;
626
632
} ;
627
633
628
634
@@ -1161,7 +1167,7 @@ function Server(options, connectionListener) {
1161
1167
if ( ! ( this instanceof Server ) )
1162
1168
return new Server ( options , connectionListener ) ;
1163
1169
1164
- EventEmitter . call ( this ) ;
1170
+ FunctionPrototypeCall ( EventEmitter , this ) ;
1165
1171
1166
1172
if ( typeof options === 'function' ) {
1167
1173
connectionListener = options ;
@@ -1687,10 +1693,10 @@ ObjectDefineProperty(Socket.prototype, '_handle', {
1687
1693
1688
1694
Server . prototype . _setupWorker = function ( socketList ) {
1689
1695
this . _usingWorkers = true ;
1690
- this . _workers . push ( socketList ) ;
1696
+ ArrayPrototypePush ( this . _workers , socketList ) ;
1691
1697
socketList . once ( 'exit' , ( socketList ) => {
1692
- const index = this . _workers . indexOf ( socketList ) ;
1693
- this . _workers . splice ( index , 1 ) ;
1698
+ const index = ArrayPrototypeIndexOf ( this . _workers , socketList ) ;
1699
+ ArrayPrototypeSplice ( this . _workers , index , 1 ) ;
1694
1700
} ) ;
1695
1701
} ;
1696
1702
0 commit comments