2
2
3
3
var isEmpty = require ( 'is-empty' )
4
4
5
- /* Detect color support. */
6
-
5
+ // Detect color support.
7
6
var color = true
8
7
9
8
try {
@@ -24,8 +23,8 @@ var dim = ansiColor(2, 22)
24
23
var yellow = ansiColor ( 33 , 39 )
25
24
var green = ansiColor ( 32 , 39 )
26
25
27
- /* Define ANSII color removal functionality. */
28
- var COLOR_EXPRESSION = new RegExp (
26
+ // Define ANSII color removal functionality.
27
+ var colorExpression = new RegExp (
29
28
'(?:' +
30
29
'(?:\\u001b\\[)|' +
31
30
'\\u009b' +
@@ -37,17 +36,16 @@ var COLOR_EXPRESSION = new RegExp(
37
36
'g'
38
37
)
39
38
40
- /* Standard keys defined by unist:
41
- * https://github.com/syntax-tree/unist.
42
- * We don’t ignore `data` though. */
39
+ // Standard keys defined by unist: https://github.com/syntax-tree/unist.
40
+ // We don’t ignore `data` though.
43
41
var ignore = [ 'type' , 'value' , 'children' , 'position' ]
44
42
45
- /* Inspects a node, without using color. */
43
+ // Inspects a node, without using color.
46
44
function noColor ( node , pad ) {
47
45
return stripColor ( inspect ( node , pad ) )
48
46
}
49
47
50
- /* Inspects a node. */
48
+ // Inspects a node.
51
49
function inspect ( node , pad ) {
52
50
var result
53
51
var children
@@ -96,12 +94,12 @@ function inspect(node, pad) {
96
94
return result . join ( '\n' )
97
95
}
98
96
99
- /* Colored nesting formatter. */
97
+ // Colored nesting formatter.
100
98
function formatNesting ( value ) {
101
99
return dim ( value )
102
100
}
103
101
104
- /* Compile a single position. */
102
+ // Compile a single position.
105
103
function compile ( pos ) {
106
104
var values = [ ]
107
105
@@ -118,7 +116,7 @@ function compile(pos) {
118
116
return values
119
117
}
120
118
121
- /* Compile a location. */
119
+ // Compile a location.
122
120
function stringify ( start , end ) {
123
121
var values = [ ]
124
122
var positions = [ ]
@@ -137,7 +135,7 @@ function stringify(start, end) {
137
135
138
136
return values . join ( ', ' )
139
137
140
- /* Add a position. */
138
+ // Add a position.
141
139
function add ( position ) {
142
140
var tuple = compile ( position )
143
141
@@ -151,7 +149,7 @@ function stringify(start, end) {
151
149
}
152
150
}
153
151
154
- /* Colored node formatter. */
152
+ // Colored node formatter.
155
153
function formatNode ( node ) {
156
154
var log = node . type
157
155
var location = node . position || { }
@@ -192,12 +190,12 @@ function formatNode(node) {
192
190
return log
193
191
}
194
192
195
- /* Remove ANSI colour from `value`. */
193
+ // Remove ANSI colour from `value`.
196
194
function stripColor ( value ) {
197
- return value . replace ( COLOR_EXPRESSION , '' )
195
+ return value . replace ( colorExpression , '' )
198
196
}
199
197
200
- /* Factory to wrap values in ANSI colours. */
198
+ // Factory to wrap values in ANSI colours.
201
199
function ansiColor ( open , close ) {
202
200
return color
203
201
0 commit comments