@@ -15,10 +15,13 @@ const {
15
15
} = require ( 'internal/errors' ) ;
16
16
const { previewEntries } = internalBinding ( 'util' ) ;
17
17
const { Buffer : { isBuffer } } = require ( 'buffer' ) ;
18
- const util = require ( 'util' ) ;
18
+ const {
19
+ inspect,
20
+ formatWithOptions
21
+ } = require ( 'internal/util/inspect' ) ;
19
22
const {
20
23
isTypedArray, isSet, isMap, isSetIterator, isMapIterator,
21
- } = util . types ;
24
+ } = require ( 'internal/ util/ types' ) ;
22
25
const kCounts = Symbol ( 'counts' ) ;
23
26
24
27
const kTraceConsoleCategory = 'node,node.console' ;
@@ -271,12 +274,12 @@ Console.prototype[kGetInspectOptions] = function(stream) {
271
274
272
275
Console . prototype [ kFormatForStdout ] = function ( args ) {
273
276
const opts = this [ kGetInspectOptions ] ( this . _stdout ) ;
274
- return util . formatWithOptions ( opts , ...args ) ;
277
+ return formatWithOptions ( opts , ...args ) ;
275
278
} ;
276
279
277
280
Console . prototype [ kFormatForStderr ] = function ( args ) {
278
281
const opts = this [ kGetInspectOptions ] ( this . _stderr ) ;
279
- return util . formatWithOptions ( opts , ...args ) ;
282
+ return formatWithOptions ( opts , ...args ) ;
280
283
} ;
281
284
282
285
const consoleMethods = {
@@ -290,7 +293,7 @@ const consoleMethods = {
290
293
} ,
291
294
292
295
dir ( object , options ) {
293
- this [ kWriteToConsole ] ( kUseStdout , util . inspect ( object , {
296
+ this [ kWriteToConsole ] ( kUseStdout , inspect ( object , {
294
297
customInspect : false ,
295
298
...this [ kGetInspectOptions ] ( this . _stdout ) ,
296
299
...options
@@ -404,7 +407,7 @@ const consoleMethods = {
404
407
if ( cliTable === undefined ) cliTable = require ( 'internal/cli_table' ) ;
405
408
const final = ( k , v ) => this . log ( cliTable ( k , v ) ) ;
406
409
407
- const inspect = ( v ) => {
410
+ const _inspect = ( v ) => {
408
411
const depth = v !== null &&
409
412
typeof v === 'object' &&
410
413
! isArray ( v ) &&
@@ -414,10 +417,10 @@ const consoleMethods = {
414
417
maxArrayLength : 3 ,
415
418
...this [ kGetInspectOptions ] ( this . _stdout )
416
419
} ;
417
- return util . inspect ( v , opt ) ;
420
+ return inspect ( v , opt ) ;
418
421
} ;
419
422
const getIndexArray = ( length ) => ArrayFrom (
420
- { length } , ( _ , i ) => inspect ( i ) ) ;
423
+ { length } , ( _ , i ) => _inspect ( i ) ) ;
421
424
422
425
const mapIter = isMapIterator ( tabularData ) ;
423
426
let isKeyValue = false ;
@@ -434,14 +437,14 @@ const consoleMethods = {
434
437
let length = 0 ;
435
438
if ( mapIter ) {
436
439
for ( ; i < tabularData . length / 2 ; ++ i ) {
437
- keys . push ( inspect ( tabularData [ i * 2 ] ) ) ;
438
- values . push ( inspect ( tabularData [ i * 2 + 1 ] ) ) ;
440
+ keys . push ( _inspect ( tabularData [ i * 2 ] ) ) ;
441
+ values . push ( _inspect ( tabularData [ i * 2 + 1 ] ) ) ;
439
442
length ++ ;
440
443
}
441
444
} else {
442
445
for ( const [ k , v ] of tabularData ) {
443
- keys . push ( inspect ( k ) ) ;
444
- values . push ( inspect ( v ) ) ;
446
+ keys . push ( _inspect ( k ) ) ;
447
+ values . push ( _inspect ( v ) ) ;
445
448
length ++ ;
446
449
}
447
450
}
@@ -463,7 +466,7 @@ const consoleMethods = {
463
466
const values = [ ] ;
464
467
let length = 0 ;
465
468
for ( const v of tabularData ) {
466
- values . push ( inspect ( v ) ) ;
469
+ values . push ( _inspect ( v ) ) ;
467
470
length ++ ;
468
471
}
469
472
return final ( [ iterKey , valuesKey ] , [ getIndexArray ( length ) , values ] ) ;
@@ -480,7 +483,7 @@ const consoleMethods = {
480
483
( typeof item !== 'function' && typeof item !== 'object' ) ;
481
484
if ( properties === undefined && primitive ) {
482
485
hasPrimitives = true ;
483
- valuesKeyArray [ i ] = inspect ( item ) ;
486
+ valuesKeyArray [ i ] = _inspect ( item ) ;
484
487
} else {
485
488
const keys = properties || ObjectKeys ( item ) ;
486
489
for ( const key of keys ) {
@@ -489,7 +492,7 @@ const consoleMethods = {
489
492
if ( ( primitive && properties ) || ! hasOwnProperty ( item , key ) )
490
493
map [ key ] [ i ] = '' ;
491
494
else
492
- map [ key ] [ i ] = item == null ? item : inspect ( item [ key ] ) ;
495
+ map [ key ] [ i ] = item == null ? item : _inspect ( item [ key ] ) ;
493
496
}
494
497
}
495
498
}
0 commit comments