1
1
'use strict'
2
2
3
- /* Dependencies. */
4
3
var assert = require ( 'assert' )
5
4
var array = require ( 'x-is-array' )
6
5
var object = require ( 'x-is-object' )
@@ -10,11 +9,8 @@ var inspect
10
9
try {
11
10
// eslint-disable-next-line no-useless-concat
12
11
inspect = require ( 'ut' + 'il' ) . inspect
13
- } catch ( error ) {
14
- /* Empty. */
15
- }
12
+ } catch ( error ) { }
16
13
17
- /* Expose. */
18
14
exports = wrap ( unist )
19
15
module . exports = exports
20
16
@@ -23,14 +19,14 @@ exports.text = wrap(text)
23
19
exports . void = wrap ( empty )
24
20
exports . wrap = wrap
25
21
26
- /* Identifier to check if a value is seen. */
22
+ // Identifier to check if a value is seen.
27
23
var ID = '__unist__'
28
24
29
- /* List of specced properties. */
25
+ // List of specced properties.
30
26
var defined = [ 'type' , 'value' , 'children' , 'position' ]
31
27
32
- /* Wrapper around `Node` which adds the current node
33
- * (and parent, if available), to the message. */
28
+ // Wrapper around `Node` which adds the current node (and parent, if available),
29
+ // to the message.
34
30
function wrap ( fn ) {
35
31
return wrapped
36
32
@@ -53,7 +49,7 @@ function wrap(fn) {
53
49
}
54
50
}
55
51
56
- /* Assert. */
52
+ // Assert.
57
53
function unist ( node ) {
58
54
var type
59
55
var children
@@ -95,8 +91,8 @@ function unist(node) {
95
91
}
96
92
}
97
93
98
- /* Assert `value` (which lives at `key`) can be stringified
99
- * and re-parsed to the same (deep) value. */
94
+ // Assert `value` (which lives at `key`) can be stringified and re-parsed to the
95
+ // same (deep) value.
100
96
function vanilla ( key , value ) {
101
97
try {
102
98
assert . deepStrictEqual ( value , JSON . parse ( JSON . stringify ( value ) ) )
@@ -105,9 +101,8 @@ function vanilla(key, value) {
105
101
}
106
102
}
107
103
108
- /* Stringify a value to inspect it. Tries `JSON.stringify()`,
109
- * and if that fails uses `String()` instead. If `stringify()`
110
- * works. */
104
+ // Stringify a value to inspect it.
105
+ // Tries `JSON.stringify()`, and if that fails uses `String()` instead.
111
106
function view ( value ) {
112
107
try {
113
108
/* eslint-disable no-else-return */
@@ -124,15 +119,15 @@ function view(value) {
124
119
}
125
120
}
126
121
127
- /* Assert `node` is a parent node. */
122
+ // Assert `node` is a parent node.
128
123
function parent ( node ) {
129
124
unist ( node )
130
125
131
126
assert . strictEqual ( 'value' in node , false , 'parent should not have `value`' )
132
127
assert . ok ( 'children' in node , 'parent should have `children`' )
133
128
}
134
129
135
- /* Assert `node` is a text node. */
130
+ // Assert `node` is a text node.
136
131
function text ( node ) {
137
132
unist ( node )
138
133
@@ -144,8 +139,7 @@ function text(node) {
144
139
assert . ok ( 'value' in node , 'text should have `value`' )
145
140
}
146
141
147
- /* Assert `node` is a Unist node, but neither parent nor
148
- * text. */
142
+ // Assert `node` is a Unist node, but neither parent nor text.
149
143
function empty ( node ) {
150
144
unist ( node )
151
145
@@ -157,7 +151,7 @@ function empty(node) {
157
151
)
158
152
}
159
153
160
- /* Assert `location` is a Unist Location. */
154
+ // Assert `location` is a Unist Location.
161
155
function location ( location ) {
162
156
if ( location != null ) {
163
157
assert . ok ( object ( location ) , '`position` should be an object' )
@@ -167,7 +161,7 @@ function location(location) {
167
161
}
168
162
}
169
163
170
- /* Assert `location` is a Unist Location. */
164
+ // Assert `location` is a Unist Location.
171
165
function position ( position , name ) {
172
166
if ( position != null ) {
173
167
assert . ok ( object ( position ) , '`' + name + '` should be an object' )
0 commit comments