8
8
[ ![ Backers] [ backers-badge ]] [ collective ]
9
9
[ ![ Chat] [ chat-badge ]] [ chat ]
10
10
11
- [ ** mdast** ] [ mdast ] utility to assert trees.
11
+ [ mdast] [ ] utility to assert trees.
12
12
13
- ## Install
13
+ ## Contents
14
+
15
+ * [ What is this?] ( #what-is-this )
16
+ * [ When should I use this?] ( #when-should-i-use-this )
17
+ * [ Install] ( #install )
18
+ * [ Use] ( #use )
19
+ * [ API] ( #api )
20
+ * [ ` assert(node) ` ] ( #assertnode )
21
+ * [ Types] ( #types )
22
+ * [ Compatibility] ( #compatibility )
23
+ * [ Security] ( #security )
24
+ * [ Related] ( #related )
25
+ * [ Contribute] ( #contribute )
26
+ * [ License] ( #license )
27
+
28
+ ## What is this?
29
+
30
+ This package is a tiny utility that helps you deal with nodes.
31
+
32
+ ## When should I use this?
14
33
15
- This package is [ ESM only ] ( https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c ) :
16
- Node 12+ is needed to use it and it must be ` import ` ed instead of ` require ` d .
34
+ This utility is typically useful when you expect certain nodes in your APIs
35
+ and want to make sure they’re valid and as expected .
17
36
18
- [ npm] [ ] :
37
+ A different utility, [ ` unist-util-assert ` ] [ unist-util-assert ] , does the same but
38
+ for any [ unist] [ ] node.
39
+
40
+ ## Install
41
+
42
+ This package is [ ESM only] [ esm ] .
43
+ In Node.js (version 12.20+, 14.14+, or 16.0+), install with [ npm] [ ] :
19
44
20
45
``` sh
21
46
npm install mdast-util-assert
22
47
```
23
48
49
+ In Deno with [ ` esm.sh ` ] [ esmsh ] :
50
+
51
+ ``` js
52
+ import {assert } from ' https://esm.sh/mdast-util-assert@4'
53
+ ```
54
+
55
+ In browsers with [ ` esm.sh ` ] [ esmsh ] :
56
+
57
+ ``` html
58
+ <script type =" module" >
59
+ import {assert } from ' https://esm.sh/mdast-util-assert@4?bundle'
60
+ </script >
61
+ ```
62
+
24
63
## Use
25
64
26
65
``` js
@@ -40,8 +79,8 @@ assert({type: 'paragraph', value: 'foo'})
40
79
41
80
## API
42
81
43
- This package exports the following identifiers: ` assert ` , ` parent ` , ` literal ` ,
44
- ` _void ` , ` wrap ` .
82
+ This package exports the identifiers ` assert ` , ` parent ` , ` literal ` , ` _void ` ,
83
+ and ` wrap ` .
45
84
There is no default export.
46
85
47
86
### ` assert(node) `
@@ -50,7 +89,27 @@ Assert that [`tree`][tree] is a valid [mdast][] [node][].
50
89
If ` tree ` is a [ parent] [ ] , all [ child] [ ] ren will be asserted as well.
51
90
52
91
The ` parent ` , ` literal ` , ` _void ` , and ` wrap ` methods from
53
- [ ` unist-util-assert ` ] [ unist-util-assert ] are also included.
92
+ [ ` unist-util-assert ` ] [ unist-util-assert ] are also exported.
93
+
94
+ ###### Throws
95
+
96
+ When ` node ` , or one of its children, is not a valid mdast node.
97
+
98
+ ###### Returns
99
+
100
+ Nothing.
101
+
102
+ ## Types
103
+
104
+ This package is fully typed with [ TypeScript] [ ] .
105
+ It does not export additional types.
106
+
107
+ ## Compatibility
108
+
109
+ Projects maintained by the unified collective are compatible with all maintained
110
+ versions of Node.js.
111
+ As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
112
+ Our projects sometimes work with older versions, but this is not guaranteed.
54
113
55
114
## Security
56
115
@@ -60,16 +119,16 @@ openings for [cross-site scripting (XSS)][xss] attacks.
60
119
## Related
61
120
62
121
* [ ` unist-util-assert ` ] [ unist-util-assert ]
63
- — check [ unist] ( https://github.com/syntax-tree/unist ) nodes
122
+ — check unist nodes
64
123
* [ ` hast-util-assert ` ] ( https://github.com/syntax-tree/hast-util-assert )
65
- — check [ hast] ( https://github.com/syntax-tree/hast ) nodes
124
+ — check hast nodes
66
125
* [ ` nlcst-test ` ] ( https://github.com/syntax-tree/nlcst-test )
67
- — check [ nlcst] ( https://github.com/syntax-tree/nlcst ) nodes
126
+ — check nlcst nodes
68
127
69
128
## Contribute
70
129
71
- See [ ` contributing.md ` in ` syntax-tree/.github ` ] [ contributing ] for ways to get
72
- started.
130
+ See [ ` contributing.md ` ] [ contributing ] in [ ` syntax-tree/.github ` ] [ health ] for
131
+ ways to get started.
73
132
See [ ` support.md ` ] [ support ] for ways to get help.
74
133
75
134
This project has a [ code of conduct] [ coc ] .
@@ -110,28 +169,38 @@ abide by its terms.
110
169
111
170
[ npm ] : https://docs.npmjs.com/cli/install
112
171
172
+ [ esm ] : https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
173
+
174
+ [ esmsh ] : https://esm.sh
175
+
176
+ [ typescript ] : https://www.typescriptlang.org
177
+
113
178
[ license ] : license
114
179
115
180
[ author ] : https://wooorm.com
116
181
117
- [ contributing ] : https://github.com/syntax-tree/.github/blob/HEAD/contributing.md
182
+ [ health ] : https://github.com/syntax-tree/.github
118
183
119
- [ support ] : https://github.com/syntax-tree/.github/blob/HEAD/support .md
184
+ [ contributing ] : https://github.com/syntax-tree/.github/blob/main/contributing .md
120
185
121
- [ coc ] : https://github.com/syntax-tree/.github/blob/HEAD/code-of-conduct .md
186
+ [ support ] : https://github.com/syntax-tree/.github/blob/main/support .md
122
187
123
- [ mdast ] : https://github.com/syntax-tree/mdast
188
+ [ coc ] : https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
124
189
125
- [ unist-util-assert ] : https://github.com/syntax-tree/unist-util-assert
190
+ [ xss ] : https://en.wikipedia.org/wiki/Cross-site_scripting
191
+
192
+ [ unist ] : https://github.com/syntax-tree/unist
126
193
127
194
[ tree ] : https://github.com/syntax-tree/unist#tree
128
195
129
196
[ child ] : https://github.com/syntax-tree/unist#child
130
197
198
+ [ unist-util-assert ] : https://github.com/syntax-tree/unist-util-assert
199
+
200
+ [ mdast ] : https://github.com/syntax-tree/mdast
201
+
131
202
[ node ] : https://github.com/syntax-tree/mdast#nodes
132
203
133
204
[ parent ] : https://github.com/syntax-tree/mdast#parent
134
205
135
- [ xss ] : https://en.wikipedia.org/wiki/Cross-site_scripting
136
-
137
206
[ hast ] : https://github.com/syntax-tree/hast
0 commit comments