28
28
const FS = require ( 'fs' ) ;
29
29
const Path = require ( 'path' ) ;
30
30
const Repl = require ( 'repl' ) ;
31
- const util = require ( 'util' ) ;
32
31
const vm = require ( 'vm' ) ;
33
- const fileURLToPath = require ( 'url' ) . fileURLToPath ;
32
+ const { fileURLToPath } = require ( 'internal/ url' ) ;
34
33
35
- const debuglog = util . debuglog ( 'inspect' ) ;
34
+ const { customInspectSymbol } = require ( 'internal/util' ) ;
35
+ const { inspect : utilInspect } = require ( 'internal/util/inspect' ) ;
36
+ const debuglog = require ( 'internal/util/debuglog' ) . debuglog ( 'inspect' ) ;
36
37
37
38
const SHORTCUTS = {
38
39
cont : 'c' ,
@@ -170,12 +171,12 @@ class RemoteObject {
170
171
}
171
172
}
172
173
173
- [ util . inspect . custom ] ( depth , opts ) {
174
+ [ customInspectSymbol ] ( depth , opts ) {
174
175
function formatProperty ( prop ) {
175
176
switch ( prop . type ) {
176
177
case 'string' :
177
178
case 'undefined' :
178
- return util . inspect ( prop . value , opts ) ;
179
+ return utilInspect ( prop . value , opts ) ;
179
180
180
181
case 'number' :
181
182
case 'boolean' :
@@ -184,7 +185,7 @@ class RemoteObject {
184
185
case 'object' :
185
186
case 'symbol' :
186
187
if ( prop . subtype === 'date' ) {
187
- return util . inspect ( new Date ( prop . value ) , opts ) ;
188
+ return utilInspect ( new Date ( prop . value ) , opts ) ;
188
189
}
189
190
if ( prop . subtype === 'array' ) {
190
191
return opts . stylize ( prop . value , 'special' ) ;
@@ -200,7 +201,7 @@ class RemoteObject {
200
201
case 'number' :
201
202
case 'string' :
202
203
case 'undefined' :
203
- return util . inspect ( this . value , opts ) ;
204
+ return utilInspect ( this . value , opts ) ;
204
205
205
206
case 'symbol' :
206
207
return opts . stylize ( this . description , 'special' ) ;
@@ -214,10 +215,10 @@ class RemoteObject {
214
215
case 'object' :
215
216
switch ( this . subtype ) {
216
217
case 'date' :
217
- return util . inspect ( new Date ( this . description ) , opts ) ;
218
+ return utilInspect ( new Date ( this . description ) , opts ) ;
218
219
219
220
case 'null' :
220
- return util . inspect ( null , opts ) ;
221
+ return utilInspect ( null , opts ) ;
221
222
222
223
case 'regexp' :
223
224
return opts . stylize ( this . description , 'regexp' ) ;
@@ -265,11 +266,11 @@ class ScopeSnapshot {
265
266
this . completionGroup = properties . map ( ( prop ) => prop . name ) ;
266
267
}
267
268
268
- [ util . inspect . custom ] ( depth , opts ) {
269
+ [ customInspectSymbol ] ( depth , opts ) {
269
270
const type = `${ this . type [ 0 ] . toUpperCase ( ) } ${ this . type . slice ( 1 ) } ` ;
270
271
const name = this . name ? `<${ this . name } >` : '' ;
271
272
const prefix = `${ type } ${ name } ` ;
272
- return util . inspect ( this . properties , opts )
273
+ return utilInspect ( this . properties , opts )
273
274
. replace ( / ^ M a p / , prefix ) ;
274
275
}
275
276
}
@@ -318,7 +319,7 @@ function createRepl(inspector) {
318
319
319
320
const INSPECT_OPTIONS = { colors : inspector . stdout . isTTY } ;
320
321
function inspect ( value ) {
321
- return util . inspect ( value , INSPECT_OPTIONS ) ;
322
+ return utilInspect ( value , INSPECT_OPTIONS ) ;
322
323
}
323
324
324
325
function print ( value , addNewline = true ) {
@@ -358,7 +359,7 @@ function createRepl(inspector) {
358
359
function listScripts ( displayNatives = false ) {
359
360
print ( formatScripts ( displayNatives ) ) ;
360
361
}
361
- listScripts [ util . inspect . custom ] = function listWithoutInternal ( ) {
362
+ listScripts [ customInspectSymbol ] = function listWithoutInternal ( ) {
362
363
return formatScripts ( ) ;
363
364
} ;
364
365
@@ -374,7 +375,7 @@ function createRepl(inspector) {
374
375
return p ;
375
376
}
376
377
377
- [ util . inspect . custom ] ( depth , { stylize } ) {
378
+ [ customInspectSymbol ] ( depth , { stylize } ) {
378
379
const { startTime, endTime } = this . data ;
379
380
const MU = String . fromChar ( 956 ) ;
380
381
return stylize ( `[Profile ${ endTime - startTime } ${ MU } s]` , 'special' ) ;
@@ -395,7 +396,7 @@ function createRepl(inspector) {
395
396
this . delta = delta ;
396
397
}
397
398
398
- [ util . inspect . custom ] ( depth , options ) {
399
+ [ customInspectSymbol ] ( depth , options ) {
399
400
const { scriptId, lineNumber, columnNumber, delta, scriptSource } = this ;
400
401
const start = Math . max ( 1 , lineNumber - delta + 1 ) ;
401
402
const end = lineNumber + delta + 1 ;
@@ -461,7 +462,7 @@ function createRepl(inspector) {
461
462
}
462
463
463
464
class Backtrace extends Array {
464
- [ util . inspect . custom ] ( ) {
465
+ [ customInspectSymbol ] ( ) {
465
466
return this . map ( ( callFrame , idx ) => {
466
467
const {
467
468
location : { scriptId, lineNumber, columnNumber } ,
0 commit comments