@@ -193,7 +193,7 @@ function inspect(value, opts) {
193193}
194194if ( ctx . colors ) ctx . stylize = stylizeWithColor ;
195195if ( ctx . maxArrayLength === null ) ctx . maxArrayLength = Infinity ;
196- return formatValue ( ctx , value , ctx . depth ) ;
196+ return formatValue ( ctx , value , 0 ) ;
197197}
198198inspect . custom = customInspectSymbol ;
199199
@@ -407,11 +407,10 @@ function getCtxStyle(constructor, tag) {
407407}
408408
409409function formatProxy ( ctx , proxy , recurseTimes ) {
410- if ( recurseTimes != null ) {
411- if ( recurseTimes < 0 )
412- return ctx . stylize ( 'Proxy [Array]' , 'special' ) ;
413- recurseTimes -= 1 ;
410+ if ( recurseTimes > ctx . depth && ctx . depth !== null ) {
411+ return ctx . stylize ( 'Proxy [Array]' , 'special' ) ;
414412}
413+ recurseTimes += 1 ;
415414ctx . indentationLvl += 2 ;
416415const res = [
417416formatValue ( ctx , proxy [ 0 ] , recurseTimes ) ,
@@ -526,7 +525,10 @@ function formatValue(ctx, value, recurseTimes, typedArray) {
526525maybeCustom !== inspect &&
527526// Also filter out any prototype objects using the circular check.
528527! ( value . constructor && value . constructor . prototype === value ) ) {
529- const ret = maybeCustom . call ( value , recurseTimes , ctx ) ;
528+ // This makes sure the recurseTimes are reported as before while using
529+ // a counter internally.
530+ const depth = ctx . depth === null ? null : ctx . depth - recurseTimes ;
531+ const ret = maybeCustom . call ( value , depth , ctx ) ;
530532
531533// If the custom inspection method returned `this`, don't go into
532534// infinite recursion.
@@ -643,7 +645,7 @@ function formatRaw(ctx, value, recurseTimes, typedArray) {
643645const prefix = getPrefix ( constructor , tag , 'RegExp' ) ;
644646if ( prefix !== 'RegExp ' )
645647base = `${ prefix } ${ base } ` ;
646- if ( keys . length === 0 || recurseTimes < 0 )
648+ if ( keys . length === 0 || recurseTimes > ctx . depth && ctx . depth !== null )
647649return ctx . stylize ( base , 'regexp' ) ;
648650} else if ( isDate ( value ) ) {
649651// Make dates with properties first say the date
@@ -757,11 +759,10 @@ function formatRaw(ctx, value, recurseTimes, typedArray) {
757759}
758760}
759761
760- if ( recurseTimes != null ) {
761- if ( recurseTimes < 0 )
762- return ctx . stylize ( `[${ getCtxStyle ( constructor , tag ) } ]` , 'special' ) ;
763- recurseTimes -= 1 ;
762+ if ( recurseTimes > ctx . depth && ctx . depth !== null ) {
763+ return ctx . stylize ( `[${ getCtxStyle ( constructor , tag ) } ]` , 'special' ) ;
764764}
765+ recurseTimes += 1 ;
765766
766767ctx . seen . push ( value ) ;
767768let output ;
0 commit comments