@@ -26,6 +26,7 @@ const { TextDecoder, TextEncoder } = require('internal/encoding');
2626const { isBuffer } = require ( 'buffer' ) . Buffer ;
2727
2828const { errname } = process . binding ( 'uv' ) ;
29+ const { previewMapIterator, previewSetIterator } = require ( 'internal/v8' ) ;
2930
3031const {
3132 getPromiseDetails,
@@ -77,7 +78,6 @@ const dateToISOString = Date.prototype.toISOString;
7778const errorToString = Error . prototype . toString ;
7879
7980var CIRCULAR_ERROR_MESSAGE ;
80- var Debug ;
8181
8282/* eslint-disable */
8383const strEscapeSequencesRegExp = / [ \x00 - \x1f \x27 \x5c ] / ;
@@ -356,17 +356,6 @@ function stylizeNoColor(str, styleType) {
356356 return str ;
357357}
358358
359- function ensureDebugIsInitialized ( ) {
360- if ( Debug === undefined ) {
361- const runInDebugContext = require ( 'vm' ) . runInDebugContext ;
362- // a workaround till this entire method is removed
363- const originalValue = process . noDeprecation ;
364- process . noDeprecation = true ;
365- Debug = runInDebugContext ( 'Debug' ) ;
366- process . noDeprecation = originalValue ;
367- }
368- }
369-
370359function formatValue ( ctx , value , recurseTimes , ln ) {
371360 // Primitive types cannot have properties
372361 if ( typeof value !== 'object' && typeof value !== 'function' ) {
@@ -474,10 +463,10 @@ function formatValue(ctx, value, recurseTimes, ln) {
474463 formatter = formatTypedArray ;
475464 } else if ( isMapIterator ( value ) ) {
476465 braces = [ 'MapIterator {' , '}' ] ;
477- formatter = formatCollectionIterator ;
466+ formatter = formatMapIterator ;
478467 } else if ( isSetIterator ( value ) ) {
479468 braces = [ 'SetIterator {' , '}' ] ;
480- formatter = formatCollectionIterator ;
469+ formatter = formatSetIterator ;
481470 } else {
482471 // Check for boxed strings with valueOf()
483472 // The .valueOf() call can fail for a multitude of reasons
@@ -782,17 +771,27 @@ function formatMap(ctx, value, recurseTimes, keys) {
782771 return output ;
783772}
784773
785- function formatCollectionIterator ( ctx , value , recurseTimes , keys ) {
786- ensureDebugIsInitialized ( ) ;
787- const mirror = Debug . MakeMirror ( value , true ) ;
788- const vals = mirror . preview ( ) ;
789- const output = [ ] ;
774+ function formatCollectionIterator ( preview , ctx , value , recurseTimes ,
775+ visibleKeys , keys ) {
776+ var nextRecurseTimes = recurseTimes === null ? null : recurseTimes - 1 ;
777+ var vals = preview ( value , 100 ) ;
778+ var output = [ ] ;
790779 for ( const o of vals ) {
791- output . push ( formatValue ( ctx , o , recurseTimes ) ) ;
780+ output . push ( formatValue ( ctx , o , nextRecurseTimes ) ) ;
792781 }
793782 return output ;
794783}
795784
785+ function formatMapIterator ( ctx , value , recurseTimes , visibleKeys , keys ) {
786+ return formatCollectionIterator ( previewMapIterator , ctx , value , recurseTimes ,
787+ visibleKeys , keys ) ;
788+ }
789+
790+ function formatSetIterator ( ctx , value , recurseTimes , visibleKeys , keys ) {
791+ return formatCollectionIterator ( previewSetIterator , ctx , value , recurseTimes ,
792+ visibleKeys , keys ) ;
793+ }
794+
796795function formatPromise ( ctx , value , recurseTimes , keys ) {
797796 var output ;
798797 const [ state , result ] = getPromiseDetails ( value ) ;
0 commit comments