@@ -26,6 +26,7 @@ const { TextDecoder, TextEncoder } = require('internal/encoding');
26
26
const { isBuffer } = require ( 'buffer' ) . Buffer ;
27
27
28
28
const { errname } = process . binding ( 'uv' ) ;
29
+ const { previewMapIterator, previewSetIterator } = require ( 'internal/v8' ) ;
29
30
30
31
const {
31
32
getPromiseDetails,
@@ -77,7 +78,6 @@ const dateToISOString = Date.prototype.toISOString;
77
78
const errorToString = Error . prototype . toString ;
78
79
79
80
var CIRCULAR_ERROR_MESSAGE ;
80
- var Debug ;
81
81
82
82
/* eslint-disable */
83
83
const strEscapeSequencesRegExp = / [ \x00 - \x1f \x27 \x5c ] / ;
@@ -356,17 +356,6 @@ function stylizeNoColor(str, styleType) {
356
356
return str ;
357
357
}
358
358
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
-
370
359
function formatValue ( ctx , value , recurseTimes , ln ) {
371
360
// Primitive types cannot have properties
372
361
if ( typeof value !== 'object' && typeof value !== 'function' ) {
@@ -474,10 +463,10 @@ function formatValue(ctx, value, recurseTimes, ln) {
474
463
formatter = formatTypedArray ;
475
464
} else if ( isMapIterator ( value ) ) {
476
465
braces = [ 'MapIterator {' , '}' ] ;
477
- formatter = formatCollectionIterator ;
466
+ formatter = formatMapIterator ;
478
467
} else if ( isSetIterator ( value ) ) {
479
468
braces = [ 'SetIterator {' , '}' ] ;
480
- formatter = formatCollectionIterator ;
469
+ formatter = formatSetIterator ;
481
470
} else {
482
471
// Check for boxed strings with valueOf()
483
472
// The .valueOf() call can fail for a multitude of reasons
@@ -782,17 +771,27 @@ function formatMap(ctx, value, recurseTimes, keys) {
782
771
return output ;
783
772
}
784
773
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 = [ ] ;
790
779
for ( const o of vals ) {
791
- output . push ( formatValue ( ctx , o , recurseTimes ) ) ;
780
+ output . push ( formatValue ( ctx , o , nextRecurseTimes ) ) ;
792
781
}
793
782
return output ;
794
783
}
795
784
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
+
796
795
function formatPromise ( ctx , value , recurseTimes , keys ) {
797
796
var output ;
798
797
const [ state , result ] = getPromiseDetails ( value ) ;
0 commit comments