@@ -514,54 +514,53 @@ function makeTextDecoderJS() {
514514}
515515
516516// Mix in some shared properties.
517- {
518- ObjectDefineProperties (
519- TextDecoder . prototype ,
520- ObjectGetOwnPropertyDescriptors ( {
521- get encoding ( ) {
522- validateDecoder ( this ) ;
523- return this [ kEncoding ] ;
524- } ,
525-
526- get fatal ( ) {
527- validateDecoder ( this ) ;
528- return ( this [ kFlags ] & CONVERTER_FLAGS_FATAL ) === CONVERTER_FLAGS_FATAL ;
529- } ,
530-
531- get ignoreBOM ( ) {
532- validateDecoder ( this ) ;
533- return ( this [ kFlags ] & CONVERTER_FLAGS_IGNORE_BOM ) ===
534- CONVERTER_FLAGS_IGNORE_BOM ;
535- } ,
536-
537- [ inspect ] ( depth , opts ) {
538- validateDecoder ( this ) ;
539- if ( typeof depth === 'number' && depth < 0 )
540- return this ;
541- const ctor = getConstructorOf ( this ) ;
542- const obj = ObjectCreate ( {
543- constructor : ctor === null ? TextDecoder : ctor
544- } ) ;
545- obj . encoding = this . encoding ;
546- obj . fatal = this . fatal ;
547- obj . ignoreBOM = this . ignoreBOM ;
548- if ( opts . showHidden ) {
549- obj [ kFlags ] = this [ kFlags ] ;
550- obj [ kHandle ] = this [ kHandle ] ;
551- }
552- // Lazy to avoid circular dependency
553- return require ( 'internal/util/inspect' ) . inspect ( obj , opts ) ;
517+ ObjectDefineProperties (
518+ TextDecoder . prototype ,
519+ ObjectGetOwnPropertyDescriptors ( {
520+ get encoding ( ) {
521+ validateDecoder ( this ) ;
522+ return this [ kEncoding ] ;
523+ } ,
524+
525+ get fatal ( ) {
526+ validateDecoder ( this ) ;
527+ return ( this [ kFlags ] & CONVERTER_FLAGS_FATAL ) === CONVERTER_FLAGS_FATAL ;
528+ } ,
529+
530+ get ignoreBOM ( ) {
531+ validateDecoder ( this ) ;
532+ return ( this [ kFlags ] & CONVERTER_FLAGS_IGNORE_BOM ) ===
533+ CONVERTER_FLAGS_IGNORE_BOM ;
534+ } ,
535+
536+ [ inspect ] ( depth , opts ) {
537+ validateDecoder ( this ) ;
538+ if ( typeof depth === 'number' && depth < 0 )
539+ return this ;
540+ const constructor = getConstructorOf ( this ) || TextDecoder ;
541+ const obj = ObjectCreate ( { constructor } ) ;
542+ obj . encoding = this . encoding ;
543+ obj . fatal = this . fatal ;
544+ obj . ignoreBOM = this . ignoreBOM ;
545+ if ( opts . showHidden ) {
546+ obj [ kFlags ] = this [ kFlags ] ;
547+ obj [ kHandle ] = this [ kHandle ] ;
554548 }
555- } ) ) ;
556- ObjectDefineProperties ( TextDecoder . prototype , {
557- decode : { enumerable : true } ,
558- [ inspect ] : { enumerable : false } ,
559- [ SymbolToStringTag ] : {
560- configurable : true ,
561- value : 'TextDecoder'
549+ // Lazy to avoid circular dependency
550+ const { inspect } = require ( 'internal/util/inspect' ) ;
551+ return `${ constructor . name } ${ inspect ( obj ) } ` ;
562552 }
563- } ) ;
564- }
553+ } )
554+ ) ;
555+
556+ ObjectDefineProperties ( TextDecoder . prototype , {
557+ decode : { enumerable : true } ,
558+ [ inspect ] : { enumerable : false } ,
559+ [ SymbolToStringTag ] : {
560+ configurable : true ,
561+ value : 'TextDecoder'
562+ }
563+ } ) ;
565564
566565module . exports = {
567566 getEncodingFromLabel,
0 commit comments