Skip to content

Commit a571ccc

Browse files
committed
Refactor code-style
1 parent 8c817df commit a571ccc

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

index.js

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
var isEmpty = require('is-empty')
44

5-
/* Detect color support. */
6-
5+
// Detect color support.
76
var color = true
87

98
try {
@@ -24,8 +23,8 @@ var dim = ansiColor(2, 22)
2423
var yellow = ansiColor(33, 39)
2524
var green = ansiColor(32, 39)
2625

27-
/* Define ANSII color removal functionality. */
28-
var COLOR_EXPRESSION = new RegExp(
26+
// Define ANSII color removal functionality.
27+
var colorExpression = new RegExp(
2928
'(?:' +
3029
'(?:\\u001b\\[)|' +
3130
'\\u009b' +
@@ -37,17 +36,16 @@ var COLOR_EXPRESSION = new RegExp(
3736
'g'
3837
)
3938

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.
4341
var ignore = ['type', 'value', 'children', 'position']
4442

45-
/* Inspects a node, without using color. */
43+
// Inspects a node, without using color.
4644
function noColor(node, pad) {
4745
return stripColor(inspect(node, pad))
4846
}
4947

50-
/* Inspects a node. */
48+
// Inspects a node.
5149
function inspect(node, pad) {
5250
var result
5351
var children
@@ -96,12 +94,12 @@ function inspect(node, pad) {
9694
return result.join('\n')
9795
}
9896

99-
/* Colored nesting formatter. */
97+
// Colored nesting formatter.
10098
function formatNesting(value) {
10199
return dim(value)
102100
}
103101

104-
/* Compile a single position. */
102+
// Compile a single position.
105103
function compile(pos) {
106104
var values = []
107105

@@ -118,7 +116,7 @@ function compile(pos) {
118116
return values
119117
}
120118

121-
/* Compile a location. */
119+
// Compile a location.
122120
function stringify(start, end) {
123121
var values = []
124122
var positions = []
@@ -137,7 +135,7 @@ function stringify(start, end) {
137135

138136
return values.join(', ')
139137

140-
/* Add a position. */
138+
// Add a position.
141139
function add(position) {
142140
var tuple = compile(position)
143141

@@ -151,7 +149,7 @@ function stringify(start, end) {
151149
}
152150
}
153151

154-
/* Colored node formatter. */
152+
// Colored node formatter.
155153
function formatNode(node) {
156154
var log = node.type
157155
var location = node.position || {}
@@ -192,12 +190,12 @@ function formatNode(node) {
192190
return log
193191
}
194192

195-
/* Remove ANSI colour from `value`. */
193+
// Remove ANSI colour from `value`.
196194
function stripColor(value) {
197-
return value.replace(COLOR_EXPRESSION, '')
195+
return value.replace(colorExpression, '')
198196
}
199197

200-
/* Factory to wrap values in ANSI colours. */
198+
// Factory to wrap values in ANSI colours.
201199
function ansiColor(open, close) {
202200
return color
203201

0 commit comments

Comments
 (0)