|
24 | 24 | const{ |
25 | 25 | Array, |
26 | 26 | ArrayIsArray, |
| 27 | + ArrayPrototypePush, |
| 28 | + FunctionPrototypeBind, |
| 29 | + FunctionPrototypeCall, |
27 | 30 | ObjectDefineProperty, |
28 | 31 | ObjectSetPrototypeOf, |
| 32 | + ReflectApply, |
29 | 33 | }=primordials; |
30 | 34 |
|
31 | 35 | consterrors=require('internal/errors'); |
@@ -88,7 +92,7 @@ const exceptionWithHostPort = errors.exceptionWithHostPort; |
88 | 92 |
|
89 | 93 |
|
90 | 94 | functionSocket(type,listener){ |
91 | | -EventEmitter.call(this); |
| 95 | +FunctionPrototypeCall(EventEmitter,this); |
92 | 96 | letlookup; |
93 | 97 | letrecvBufferSize; |
94 | 98 | letsendBufferSize; |
@@ -235,8 +239,8 @@ Socket.prototype.bind = function(port_, address_ /* , callback */) { |
235 | 239 | } |
236 | 240 |
|
237 | 241 | functiononListening(){ |
238 | | -removeListeners.call(this); |
239 | | -cb.call(this); |
| 242 | +FunctionPrototypeCall(removeListeners,this); |
| 243 | +FunctionPrototypeCall(cb,this); |
240 | 244 | } |
241 | 245 |
|
242 | 246 | this.on('error',removeListeners); |
@@ -384,11 +388,12 @@ Socket.prototype.connect = function(port, address, callback) { |
384 | 388 | this.bind({port: 0,exclusive: true},null); |
385 | 389 |
|
386 | 390 | if(state.bindState!==BIND_STATE_BOUND){ |
387 | | -enqueue(this,_connect.bind(this,port,address,callback)); |
| 391 | +enqueue(this,FunctionPrototypeBind(_connect,this, |
| 392 | +port,address,callback)); |
388 | 393 | return; |
389 | 394 | } |
390 | 395 |
|
391 | | -_connect.call(this,port,address,callback); |
| 396 | +ReflectApply(_connect,this,[port,address,callback]); |
392 | 397 | }; |
393 | 398 |
|
394 | 399 |
|
@@ -513,13 +518,13 @@ function enqueue(self, toEnqueue) { |
513 | 518 | self.once(EventEmitter.errorMonitor,onListenError); |
514 | 519 | self.once('listening',onListenSuccess); |
515 | 520 | } |
516 | | -state.queue.push(toEnqueue); |
| 521 | +ArrayPrototypePush(state.queue,toEnqueue); |
517 | 522 | } |
518 | 523 |
|
519 | 524 |
|
520 | 525 | functiononListenSuccess(){ |
521 | 526 | this.removeListener(EventEmitter.errorMonitor,onListenError); |
522 | | -clearQueue.call(this); |
| 527 | +FunctionPrototypeCall(clearQueue,this); |
523 | 528 | } |
524 | 529 |
|
525 | 530 |
|
@@ -640,12 +645,13 @@ Socket.prototype.send = function(buffer, |
640 | 645 | this.bind({port: 0,exclusive: true},null); |
641 | 646 |
|
642 | 647 | if(list.length===0) |
643 | | -list.push(Buffer.alloc(0)); |
| 648 | +ArrayPrototypePush(list,Buffer.alloc(0)); |
644 | 649 |
|
645 | 650 | // If the socket hasn't been bound yet, push the outbound packet onto the |
646 | 651 | // send queue and send after binding is complete. |
647 | 652 | if(state.bindState!==BIND_STATE_BOUND){ |
648 | | -enqueue(this,this.send.bind(this,list,port,address,callback)); |
| 653 | +enqueue(this,FunctionPrototypeBind(this.send,this, |
| 654 | +list,port,address,callback)); |
649 | 655 | return; |
650 | 656 | } |
651 | 657 |
|
@@ -727,7 +733,7 @@ Socket.prototype.close = function(callback) { |
727 | 733 | this.on('close',callback); |
728 | 734 |
|
729 | 735 | if(queue!==undefined){ |
730 | | -queue.push(this.close.bind(this)); |
| 736 | +ArrayPrototypePush(queue,FunctionPrototypeBind(this.close,this)); |
731 | 737 | returnthis; |
732 | 738 | } |
733 | 739 |
|
|
0 commit comments