6
6
const FS = require ( 'fs' ) ;
7
7
const Path = require ( 'path' ) ;
8
8
const Repl = require ( 'repl' ) ;
9
- const util = require ( 'util' ) ;
10
9
const vm = require ( 'vm' ) ;
11
- const fileURLToPath = require ( 'url' ) . fileURLToPath ;
10
+ const { fileURLToPath } = require ( 'internal/ url' ) ;
12
11
13
- const debuglog = util . debuglog ( 'inspect' ) ;
12
+ const { customInspectSymbol } = require ( 'internal/util' ) ;
13
+ const { inspect : utilInspect } = require ( 'internal/util/inspect' ) ;
14
+ const debuglog = require ( 'internal/util/debuglog' ) . debuglog ( 'inspect' ) ;
14
15
15
16
const SHORTCUTS = {
16
17
cont : 'c' ,
@@ -148,12 +149,12 @@ class RemoteObject {
148
149
}
149
150
}
150
151
151
- [ util . inspect . custom ] ( depth , opts ) {
152
+ [ customInspectSymbol ] ( depth , opts ) {
152
153
function formatProperty ( prop ) {
153
154
switch ( prop . type ) {
154
155
case 'string' :
155
156
case 'undefined' :
156
- return util . inspect ( prop . value , opts ) ;
157
+ return utilInspect ( prop . value , opts ) ;
157
158
158
159
case 'number' :
159
160
case 'boolean' :
@@ -162,7 +163,7 @@ class RemoteObject {
162
163
case 'object' :
163
164
case 'symbol' :
164
165
if ( prop . subtype === 'date' ) {
165
- return util . inspect ( new Date ( prop . value ) , opts ) ;
166
+ return utilInspect ( new Date ( prop . value ) , opts ) ;
166
167
}
167
168
if ( prop . subtype === 'array' ) {
168
169
return opts . stylize ( prop . value , 'special' ) ;
@@ -178,7 +179,7 @@ class RemoteObject {
178
179
case 'number' :
179
180
case 'string' :
180
181
case 'undefined' :
181
- return util . inspect ( this . value , opts ) ;
182
+ return utilInspect ( this . value , opts ) ;
182
183
183
184
case 'symbol' :
184
185
return opts . stylize ( this . description , 'special' ) ;
@@ -192,10 +193,10 @@ class RemoteObject {
192
193
case 'object' :
193
194
switch ( this . subtype ) {
194
195
case 'date' :
195
- return util . inspect ( new Date ( this . description ) , opts ) ;
196
+ return utilInspect ( new Date ( this . description ) , opts ) ;
196
197
197
198
case 'null' :
198
- return util . inspect ( null , opts ) ;
199
+ return utilInspect ( null , opts ) ;
199
200
200
201
case 'regexp' :
201
202
return opts . stylize ( this . description , 'regexp' ) ;
@@ -243,11 +244,11 @@ class ScopeSnapshot {
243
244
this . completionGroup = properties . map ( ( prop ) => prop . name ) ;
244
245
}
245
246
246
- [ util . inspect . custom ] ( depth , opts ) {
247
+ [ customInspectSymbol ] ( depth , opts ) {
247
248
const type = `${ this . type [ 0 ] . toUpperCase ( ) } ${ this . type . slice ( 1 ) } ` ;
248
249
const name = this . name ? `<${ this . name } >` : '' ;
249
250
const prefix = `${ type } ${ name } ` ;
250
- return util . inspect ( this . properties , opts )
251
+ return utilInspect ( this . properties , opts )
251
252
. replace ( / ^ M a p / , prefix ) ;
252
253
}
253
254
}
@@ -296,7 +297,7 @@ function createRepl(inspector) {
296
297
297
298
const INSPECT_OPTIONS = { colors : inspector . stdout . isTTY } ;
298
299
function inspect ( value ) {
299
- return util . inspect ( value , INSPECT_OPTIONS ) ;
300
+ return utilInspect ( value , INSPECT_OPTIONS ) ;
300
301
}
301
302
302
303
function print ( value , addNewline = true ) {
@@ -336,7 +337,7 @@ function createRepl(inspector) {
336
337
function listScripts ( displayNatives = false ) {
337
338
print ( formatScripts ( displayNatives ) ) ;
338
339
}
339
- listScripts [ util . inspect . custom ] = function listWithoutInternal ( ) {
340
+ listScripts [ customInspectSymbol ] = function listWithoutInternal ( ) {
340
341
return formatScripts ( ) ;
341
342
} ;
342
343
@@ -352,7 +353,7 @@ function createRepl(inspector) {
352
353
return p ;
353
354
}
354
355
355
- [ util . inspect . custom ] ( depth , { stylize } ) {
356
+ [ customInspectSymbol ] ( depth , { stylize } ) {
356
357
const { startTime, endTime } = this . data ;
357
358
const MU = String . fromChar ( 956 ) ;
358
359
return stylize ( `[Profile ${ endTime - startTime } ${ MU } s]` , 'special' ) ;
@@ -373,7 +374,7 @@ function createRepl(inspector) {
373
374
this . delta = delta ;
374
375
}
375
376
376
- [ util . inspect . custom ] ( depth , options ) {
377
+ [ customInspectSymbol ] ( depth , options ) {
377
378
const { scriptId, lineNumber, columnNumber, delta, scriptSource } = this ;
378
379
const start = Math . max ( 1 , lineNumber - delta + 1 ) ;
379
380
const end = lineNumber + delta + 1 ;
@@ -439,7 +440,7 @@ function createRepl(inspector) {
439
440
}
440
441
441
442
class Backtrace extends Array {
442
- [ util . inspect . custom ] ( ) {
443
+ [ customInspectSymbol ] ( ) {
443
444
return this . map ( ( callFrame , idx ) => {
444
445
const {
445
446
location : { scriptId, lineNumber, columnNumber } ,
0 commit comments