8
8
[ ![ Backers] [ backers-badge ]] [ collective ]
9
9
[ ![ Chat] [ chat-badge ]] [ chat ]
10
10
11
- Assert [ Unist ] [ ] nodes .
11
+ [ ** unist ** ] [ unist ] utility to assert trees .
12
12
13
- ## Installation
13
+ ## Install
14
14
15
15
[ npm] [ ] :
16
16
@@ -20,7 +20,7 @@ npm install unist-util-assert
20
20
21
21
## Usage
22
22
23
- ``` javascript
23
+ ``` js
24
24
var assert = require (' unist-util-assert' )
25
25
26
26
assert ({type: ' root' , children: []})
@@ -46,41 +46,43 @@ assert({type: 'paragraph', children: ['foo']})
46
46
47
47
## API
48
48
49
- ### ` assert(node ) `
49
+ ### ` assert(tree ) `
50
50
51
- Assert that ` node ` is a valid [ Unist ] [ ] node. If ` node ` has ` children ` ,
52
- all children will be asserted as well.
51
+ Assert that [ ` tree ` ] [ tree ] is a valid [ unist ] [ ] [ node] [ ] .
52
+ If ` tree ` is a [ parent ] [ ] , all [ child ] [ ] ren will be asserted as well.
53
53
54
- ### ` assert.parent(node ) `
54
+ ### ` assert.parent(tree ) `
55
55
56
- Assert that ` node ` is a valid Unist [ Parent] [ ] .
56
+ Assert that ` tree ` is a valid [ unist] [ ] [ parent] [ ] .
57
+ All [ child] [ ] ren will be asserted as well.
57
58
58
59
### ` assert.text(node) `
59
60
60
- Assert that ` node ` is a valid Unist [ Text ] [ ] .
61
+ Assert that ` node ` is a valid [ unist ] [ ] [ literal ] [ ] .
61
62
62
63
### ` assert.void(node) `
63
64
64
- Assert that ` node ` is a valid Unist node, but neither Text nor Parent.
65
+ Assert that ` node ` is a valid [ unist] [ ] [ node] [ ] , but neither [ parent] [ ] nor
66
+ [ literal] [ ] .
65
67
66
68
## Extensions
67
69
68
- This module can be used as a base to test subsets of Unist (for an
69
- example, see [ ` mdast-util-assert ` ] [ mdast-util-assert ] ). All functions
70
- which are exposed from such a module, and functions used internally to
71
- test child nodes , should be wrapped in ` assert.wrap ` , which adds an
72
- inspectable string of the respective node, and its parent when available,
73
- to exposed error message.
70
+ This module can be used as a base to test subsets of [ unist ] [ ] (for an example,
71
+ see [ ` mdast-util-assert ` ] [ mdast-util-assert ] ).
72
+ All functions that are exposed from such a module, and functions used internally
73
+ to test [ child] [ ] ren , should be wrapped in ` assert.wrap ` , which adds an
74
+ inspectable string of the respective node, and its parent when available, to
75
+ the exposed error message.
74
76
75
77
### ` assert.wrap(fn) `
76
78
77
- Wraps a function (which is passed a node, and an optional parent node),
78
- so that any errors thrown inside it will contain information regarding
79
- the node (and the parent, when given).
79
+ Wraps ` fn ` (which is passed a node, and an optional parent node), so that any
80
+ errors thrown inside it will contain information regarding the node (and the
81
+ parent, when given).
80
82
81
83
## Related
82
84
83
- * [ ` mdast-util-assert ` ] ( https://github.com/syntax-tree/ mdast-util-assert)
85
+ * [ ` mdast-util-assert ` ] [ mdast-util-assert ]
84
86
— Check [ mdast] ( https://github.com/syntax-tree/mdast ) nodes
85
87
* [ ` hast-util-assert ` ] ( https://github.com/syntax-tree/hast-util-assert )
86
88
— Check [ hast] ( https://github.com/syntax-tree/hast ) nodes
@@ -89,11 +91,13 @@ the node (and the parent, when given).
89
91
90
92
## Contribute
91
93
92
- See [ ` contributing.md ` in ` syntax-tree/unist ` ] [ contributing ] for ways to get
94
+ See [ ` contributing.md ` in ` syntax-tree/.github ` ] [ contributing ] for ways to get
93
95
started.
96
+ See [ ` support.md ` ] [ support ] for ways to get help.
94
97
95
- This organisation has a [ Code of Conduct] [ coc ] . By interacting with this
96
- repository, organisation, or community you agree to abide by its terms.
98
+ This project has a [ Code of Conduct] [ coc ] .
99
+ By interacting with this repository, organisation, or community you agree to
100
+ abide by its terms.
97
101
98
102
## License
99
103
@@ -133,14 +137,22 @@ repository, organisation, or community you agree to abide by its terms.
133
137
134
138
[ author ] : https://wooorm.com
135
139
140
+ [ contributing ] : https://github.com/syntax-tree/.github/blob/master/contributing.md
141
+
142
+ [ support ] : https://github.com/syntax-tree/.github/blob/master/support.md
143
+
144
+ [ coc ] : https://github.com/syntax-tree/.github/blob/master/code-of-conduct.md
145
+
136
146
[ unist ] : https://github.com/syntax-tree/unist
137
147
138
148
[ parent ] : https://github.com/syntax-tree/unist#parent
139
149
140
- [ text ] : https://github.com/syntax-tree/unist#text
150
+ [ literal ] : https://github.com/syntax-tree/unist#literal
141
151
142
- [ mdast-util-assert ] : https://github.com/syntax-tree/mdast-util-assert
152
+ [ node ] : https://github.com/syntax-tree/unist#node
153
+
154
+ [ tree ] : https://github.com/syntax-tree/unist#tree
143
155
144
- [ contributing ] : https://github.com/syntax-tree/unist/blob/master/contributing.md
156
+ [ child ] : https://github.com/syntax-tree/unist#child
145
157
146
- [ coc ] : https://github.com/syntax-tree/unist/blob/master/code-of-conduct.md
158
+ [ mdast-util-assert ] : https://github.com/syntax-tree/mdast-util-assert
0 commit comments