2121
2222'use strict' ;
2323
24- const { Object } = primordials ;
24+ const {
25+ Object : {
26+ defineProperty : ObjectDefineProperty ,
27+ setPrototypeOf : ObjectSetPrototypeOf
28+ }
29+ } = primordials ;
2530
2631const EventEmitter = require ( 'events' ) ;
2732const stream = require ( 'stream' ) ;
@@ -336,7 +341,7 @@ function Socket(options) {
336341 // makeSyncWrite adjusts this value like the original handle would, so
337342 // we need to let it do that by turning it into a writable, own
338343 // property.
339- Object . defineProperty ( this . _handle , 'bytesWritten' , {
344+ ObjectDefineProperty ( this . _handle , 'bytesWritten' , {
340345 value : 0 , writable : true
341346 } ) ;
342347 }
@@ -372,8 +377,8 @@ function Socket(options) {
372377 this [ kBytesRead ] = 0 ;
373378 this [ kBytesWritten ] = 0 ;
374379}
375- Object . setPrototypeOf ( Socket . prototype , stream . Duplex . prototype ) ;
376- Object . setPrototypeOf ( Socket , stream . Duplex ) ;
380+ ObjectSetPrototypeOf ( Socket . prototype , stream . Duplex . prototype ) ;
381+ ObjectSetPrototypeOf ( Socket , stream . Duplex ) ;
377382
378383// Refresh existing timeouts.
379384Socket . prototype . _unrefTimer = function _unrefTimer ( ) {
@@ -503,21 +508,21 @@ Socket.prototype.address = function() {
503508} ;
504509
505510
506- Object . defineProperty ( Socket . prototype , '_connecting' , {
511+ ObjectDefineProperty ( Socket . prototype , '_connecting' , {
507512 get : function ( ) {
508513 return this . connecting ;
509514 }
510515} ) ;
511516
512- Object . defineProperty ( Socket . prototype , 'pending' , {
517+ ObjectDefineProperty ( Socket . prototype , 'pending' , {
513518 get ( ) {
514519 return ! this . _handle || this . connecting ;
515520 } ,
516521 configurable : true
517522} ) ;
518523
519524
520- Object . defineProperty ( Socket . prototype , 'readyState' , {
525+ ObjectDefineProperty ( Socket . prototype , 'readyState' , {
521526 get : function ( ) {
522527 if ( this . connecting ) {
523528 return 'opening' ;
@@ -534,15 +539,15 @@ Object.defineProperty(Socket.prototype, 'readyState', {
534539} ) ;
535540
536541
537- Object . defineProperty ( Socket . prototype , 'bufferSize' , {
538- get : function ( ) { // eslint-disable-line getter-return
542+ ObjectDefineProperty ( Socket . prototype , 'bufferSize' , {
543+ get : function ( ) {
539544 if ( this . _handle ) {
540545 return this [ kLastWriteQueueSize ] + this . writableLength ;
541546 }
542547 }
543548} ) ;
544549
545- Object . defineProperty ( Socket . prototype , kUpdateTimer , {
550+ ObjectDefineProperty ( Socket . prototype , kUpdateTimer , {
546551 get : function ( ) {
547552 return this . _unrefTimer ;
548553 }
@@ -690,7 +695,7 @@ Socket.prototype._getpeername = function() {
690695} ;
691696
692697function protoGetter ( name , callback ) {
693- Object . defineProperty ( Socket . prototype , name , {
698+ ObjectDefineProperty ( Socket . prototype , name , {
694699 configurable : false ,
695700 enumerable : true ,
696701 get : callback
@@ -1162,7 +1167,7 @@ function Server(options, connectionListener) {
11621167
11631168 this . _connections = 0 ;
11641169
1165- Object . defineProperty ( this , 'connections' , {
1170+ ObjectDefineProperty ( this , 'connections' , {
11661171 get : deprecate ( ( ) => {
11671172
11681173 if ( this . _usingWorkers ) {
@@ -1186,8 +1191,8 @@ function Server(options, connectionListener) {
11861191 this . allowHalfOpen = options . allowHalfOpen || false ;
11871192 this . pauseOnConnect = ! ! options . pauseOnConnect ;
11881193}
1189- Object . setPrototypeOf ( Server . prototype , EventEmitter . prototype ) ;
1190- Object . setPrototypeOf ( Server , EventEmitter ) ;
1194+ ObjectSetPrototypeOf ( Server . prototype , EventEmitter . prototype ) ;
1195+ ObjectSetPrototypeOf ( Server , EventEmitter ) ;
11911196
11921197
11931198function toNumber ( x ) { return ( x = Number ( x ) ) >= 0 ? x : false ; }
@@ -1491,7 +1496,7 @@ function lookupAndListen(self, port, address, backlog, exclusive, flags) {
14911496 } ) ;
14921497}
14931498
1494- Object . defineProperty ( Server . prototype , 'listening' , {
1499+ ObjectDefineProperty ( Server . prototype , 'listening' , {
14951500 get : function ( ) {
14961501 return ! ! this . _handle ;
14971502 } ,
@@ -1648,12 +1653,12 @@ function emitCloseNT(self) {
16481653
16491654// Legacy alias on the C++ wrapper object. This is not public API, so we may
16501655// want to runtime-deprecate it at some point. There's no hurry, though.
1651- Object . defineProperty ( TCP . prototype , 'owner' , {
1656+ ObjectDefineProperty ( TCP . prototype , 'owner' , {
16521657 get ( ) { return this [ owner_symbol ] ; } ,
16531658 set ( v ) { return this [ owner_symbol ] = v ; }
16541659} ) ;
16551660
1656- Object . defineProperty ( Socket . prototype , '_handle' , {
1661+ ObjectDefineProperty ( Socket . prototype , '_handle' , {
16571662 get ( ) { return this [ kHandle ] ; } ,
16581663 set ( v ) { return this [ kHandle ] = v ; }
16591664} ) ;
0 commit comments