@ -6,6 +6,7 @@ const internalUtil = require('internal/util');
const binding = process . binding ( 'util' ) ;
const binding = process . binding ( 'util' ) ;
const isError = internalUtil . isError ;
const isError = internalUtil . isError ;
const kDefaultMaxLength = 100 ;
var Debug ;
var Debug ;
@ -141,6 +142,8 @@ function inspect(obj, opts) {
if ( ctx . customInspect === undefined ) ctx . customInspect = true ;
if ( ctx . customInspect === undefined ) ctx . customInspect = true ;
if ( ctx . showProxy === undefined ) ctx . showProxy = false ;
if ( ctx . showProxy === undefined ) ctx . showProxy = false ;
if ( ctx . colors ) ctx . stylize = stylizeWithColor ;
if ( ctx . colors ) ctx . stylize = stylizeWithColor ;
if ( ctx . maxArrayLength === undefined ) ctx . maxArrayLength = kDefaultMaxLength ;
if ( ctx . maxArrayLength === null ) ctx . maxArrayLength = Infinity ;
return formatValue ( ctx , obj , ctx . depth ) ;
return formatValue ( ctx , obj , ctx . depth ) ;
}
}
exports . inspect = inspect ;
exports . inspect = inspect ;
@ -579,7 +582,9 @@ function formatObject(ctx, value, recurseTimes, visibleKeys, keys) {
function formatArray ( ctx , value , recurseTimes , visibleKeys , keys ) {
function formatArray ( ctx , value , recurseTimes , visibleKeys , keys ) {
var output = [ ] ;
var output = [ ] ;
for ( var i = 0 , l = value . length ; i < l ; ++ i ) {
const maxLength = Math . min ( Math . max ( 0 , ctx . maxArrayLength ) , value . length ) ;
const remaining = value . length - maxLength ;
for ( var i = 0 ; i < maxLength ; ++ i ) {
if ( hasOwnProperty ( value , String ( i ) ) ) {
if ( hasOwnProperty ( value , String ( i ) ) ) {
output . push ( formatProperty ( ctx , value , recurseTimes , visibleKeys ,
output . push ( formatProperty ( ctx , value , recurseTimes , visibleKeys ,
String ( i ) , true ) ) ;
String ( i ) , true ) ) ;
@ -587,6 +592,9 @@ function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
output . push ( '' ) ;
output . push ( '' ) ;
}
}
}
}
if ( remaining > 0 ) {
output . push ( ` ... ${ remaining } more item ${ remaining > 1 ? 's' : '' } ` ) ;
}
keys . forEach ( function ( key ) {
keys . forEach ( function ( key ) {
if ( typeof key === 'symbol' || ! key . match ( /^\d+$/ ) ) {
if ( typeof key === 'symbol' || ! key . match ( /^\d+$/ ) ) {
output . push ( formatProperty ( ctx , value , recurseTimes , visibleKeys ,
output . push ( formatProperty ( ctx , value , recurseTimes , visibleKeys ,
@ -598,9 +606,14 @@ function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
function formatTypedArray ( ctx , value , recurseTimes , visibleKeys , keys ) {
function formatTypedArray ( ctx , value , recurseTimes , visibleKeys , keys ) {
var output = new Array ( value . length ) ;
const maxLength = Math . min ( Math . max ( 0 , ctx . maxArrayLength ) , value . length ) ;
for ( var i = 0 , l = value . length ; i < l ; ++ i )
const remaining = value . length - maxLength ;
var output = new Array ( maxLength ) ;
for ( var i = 0 ; i < maxLength ; ++ i )
output [ i ] = formatNumber ( ctx , value [ i ] ) ;
output [ i ] = formatNumber ( ctx , value [ i ] ) ;
if ( remaining > 0 ) {
output . push ( ` ... ${ remaining } more item ${ remaining > 1 ? 's' : '' } ` ) ;
}
for ( const key of keys ) {
for ( const key of keys ) {
if ( typeof key === 'symbol' || ! key . match ( /^\d+$/ ) ) {
if ( typeof key === 'symbol' || ! key . match ( /^\d+$/ ) ) {
output . push (
output . push (