File tree Expand file tree Collapse file tree 2 files changed +22
-7
lines changed Expand file tree Collapse file tree 2 files changed +22
-7
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ const {
2424const { Buffer } = require ( 'buffer' ) ;
2525const { isArrayBufferView } = require ( 'internal/util/types' ) ;
2626const {
27+ customInspect,
2728 getAllowUnauthorized,
2829 getSocketType,
2930 lookup4,
@@ -638,14 +639,12 @@ class QuicEndpoint {
638639 socket [ kHandle ] . addEndpoint ( handle , preferred ) ;
639640 }
640641
641- [ kInspect ] ( ) {
642- // TODO(@jasnell): Proper custom inspect implementation
643- const obj = {
642+ [ kInspect ] ( depth , options ) {
643+ return customInspect ( this , {
644644 address : this . address ,
645- fd : this [ kInternalState ] . fd ,
645+ fd : this . fd ,
646646 type : this [ kInternalState ] . type === AF_INET6 ? 'udp6' : 'udp4'
647- } ;
648- return `QuicEndpoint ${ util . format ( obj ) } ` ;
647+ } , depth , options ) ;
649648 }
650649
651650 // afterLookup is invoked when binding a QuicEndpoint. The first
@@ -741,7 +740,8 @@ class QuicEndpoint {
741740 }
742741
743742 get fd ( ) {
744- return this [ kInternalState ] . fd ;
743+ return this [ kInternalState ] . fd >= 0 ?
744+ this [ kInternalState ] . fd : undefined ;
745745 }
746746
747747 // True if the QuicEndpoint has been destroyed and is
Original file line number Diff line number Diff line change @@ -23,6 +23,8 @@ const {
2323 } ,
2424} = require ( 'internal/async_hooks' ) ;
2525
26+ const { inspect } = require ( 'internal/util/inspect' ) ;
27+
2628const { Readable } = require ( 'stream' ) ;
2729const {
2830 kHandle,
@@ -955,7 +957,20 @@ class QLogStream extends Readable {
955957 }
956958}
957959
960+ function customInspect ( self , obj , depth , options ) {
961+ if ( depth < 0 )
962+ return self ;
963+
964+ const opts = {
965+ ...options ,
966+ depth : options . depth == null ? null : options . depth - 1
967+ } ;
968+
969+ return `${ self . constructor . name } ${ inspect ( obj , opts ) } ` ;
970+ }
971+
958972module . exports = {
973+ customInspect,
959974 getAllowUnauthorized,
960975 getSocketType,
961976 lookup4,
You can’t perform that action at this time.
0 commit comments