File tree Expand file tree Collapse file tree 1 file changed +27
-7
lines changed Expand file tree Collapse file tree 1 file changed +27
-7
lines changed Original file line number Diff line number Diff line change @@ -44,12 +44,6 @@ export const inspect = color ? inspectColor : inspectNoColor
44
44
45
45
const own = { } . hasOwnProperty
46
46
47
- // ANSI color regex.
48
- /* eslint-disable no-control-regex */
49
- const colorExpression =
50
- / (?: (?: \u001B \[ ) | \u009B ) (?: \d { 1 , 3 } ) ? (?: (?: ; \d { 0 , 3 } ) * ) ? [ A - M | f - m ] | \u001B [ A - M ] / g
51
- /* eslint-enable no-control-regex */
52
-
53
47
/**
54
48
* Inspect a node, without color.
55
49
*
@@ -61,7 +55,23 @@ const colorExpression =
61
55
* Pretty printed `tree`.
62
56
*/
63
57
export function inspectNoColor ( tree , options ) {
64
- return inspectColor ( tree , options ) . replace ( colorExpression , '' )
58
+ /** @type {State } */
59
+ const state = {
60
+ style : {
61
+ bold : noColor ,
62
+ dim : noColor ,
63
+ yellow : noColor ,
64
+ green : noColor
65
+ } ,
66
+ showPositions :
67
+ ! options ||
68
+ options . showPositions === null ||
69
+ options . showPositions === undefined
70
+ ? true
71
+ : options . showPositions
72
+ }
73
+
74
+ return inspectValue ( tree , state )
65
75
}
66
76
67
77
/**
@@ -403,6 +413,16 @@ function ansiColor(open, close) {
403
413
}
404
414
}
405
415
416
+ /**
417
+ * Style function which does not perform colorization.
418
+ *
419
+ * @param {string } value
420
+ * @return {string }
421
+ */
422
+ function noColor ( value ) {
423
+ return value
424
+ }
425
+
406
426
/**
407
427
* @param {unknown } value
408
428
* @returns {value is Node }
You can’t perform that action at this time.
0 commit comments