File tree 2 files changed +22
-7
lines changed
2 files changed +22
-7
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ const {
24
24
const { Buffer } = require ( 'buffer' ) ;
25
25
const { isArrayBufferView } = require ( 'internal/util/types' ) ;
26
26
const {
27
+ customInspect,
27
28
getAllowUnauthorized,
28
29
getSocketType,
29
30
lookup4,
@@ -638,14 +639,12 @@ class QuicEndpoint {
638
639
socket [ kHandle ] . addEndpoint ( handle , preferred ) ;
639
640
}
640
641
641
- [ kInspect ] ( ) {
642
- // TODO(@jasnell): Proper custom inspect implementation
643
- const obj = {
642
+ [ kInspect ] ( depth , options ) {
643
+ return customInspect ( this , {
644
644
address : this . address ,
645
- fd : this [ kInternalState ] . fd ,
645
+ fd : this . fd ,
646
646
type : this [ kInternalState ] . type === AF_INET6 ? 'udp6' : 'udp4'
647
- } ;
648
- return `QuicEndpoint ${ util . format ( obj ) } ` ;
647
+ } , depth , options ) ;
649
648
}
650
649
651
650
// afterLookup is invoked when binding a QuicEndpoint. The first
@@ -741,7 +740,8 @@ class QuicEndpoint {
741
740
}
742
741
743
742
get fd ( ) {
744
- return this [ kInternalState ] . fd ;
743
+ return this [ kInternalState ] . fd >= 0 ?
744
+ this [ kInternalState ] . fd : undefined ;
745
745
}
746
746
747
747
// True if the QuicEndpoint has been destroyed and is
Original file line number Diff line number Diff line change @@ -23,6 +23,8 @@ const {
23
23
} ,
24
24
} = require ( 'internal/async_hooks' ) ;
25
25
26
+ const { inspect } = require ( 'internal/util/inspect' ) ;
27
+
26
28
const { Readable } = require ( 'stream' ) ;
27
29
const {
28
30
kHandle,
@@ -955,7 +957,20 @@ class QLogStream extends Readable {
955
957
}
956
958
}
957
959
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
+
958
972
module . exports = {
973
+ customInspect,
959
974
getAllowUnauthorized,
960
975
getSocketType,
961
976
lookup4,
You can’t perform that action at this time.
0 commit comments