8
8
[ ![ Backers] [ backers-badge ]] [ collective ]
9
9
[ ![ Chat] [ chat-badge ]] [ chat ]
10
10
11
- [ ** hast** ] [ hast ] utility to assert trees.
11
+ [ hast] [ ] 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(tree) ` ] ( #asserttree )
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?
33
+
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.
36
+
37
+ A different utility, [ ` unist-util-assert ` ] [ unist-util-assert ] , does the same but
38
+ for any [ unist] [ ] node.
14
39
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.
40
+ ## Install
17
41
18
- [ npm] [ ] :
42
+ This package is [ ESM only] [ esm ] .
43
+ In Node.js (version 12.20+, 14.14+, 16.0+, or 18.0+), install with [ npm] [ ] :
19
44
20
45
``` sh
21
46
npm install hast-util-assert
22
47
```
23
48
49
+ In Deno with [ ` esm.sh ` ] [ esmsh ] :
50
+
51
+ ``` js
52
+ import {assert } from ' https://esm.sh/hast-util-assert@3'
53
+ ```
54
+
55
+ In browsers with [ ` esm.sh ` ] [ esmsh ] :
56
+
57
+ ``` html
58
+ <script type =" module" >
59
+ import {assert } from ' https://esm.sh/hast-util-assert@3?bundle'
60
+ </script >
61
+ ```
62
+
24
63
## Use
25
64
26
65
``` js
@@ -39,18 +78,37 @@ assert({type: 'element', properties: {}, children: []})
39
78
40
79
## API
41
80
42
- This package exports the following identifiers: ` assert ` , ` parent ` , ` literal ` ,
43
- ` _void ` , ` wrap ` .
81
+ This package exports the identifiers ` assert ` , ` parent ` , ` literal ` , ` _void ` ,
82
+ and ` wrap ` .
44
83
There is no default export.
45
84
46
85
### ` assert(tree) `
47
86
48
- Assert that the given ` tree ` is a valid [ ** hast** ] [ hast ] [ * tree* ] [ tree ] .
49
- If ` tree ` is a [ * parent* ] [ parent ] , all [ * children* ] [ child ] will be asserted as
50
- well.
87
+ Assert that [ ` tree ` ] [ tree ] is a valid [ hast] [ ] node.
88
+ If ` tree ` is a [ parent] [ ] , all [ child] [ ] ren will be asserted as well.
51
89
52
90
The ` parent ` , ` literal ` , ` _void ` , and ` wrap ` methods from
53
- [ ` unist-util-assert ` ] [ unist-util-assert ] are also included.
91
+ [ ` unist-util-assert ` ] [ unist-util-assert ] are also exported.
92
+
93
+ ###### Returns
94
+
95
+ Nothing.
96
+
97
+ ###### Throws
98
+
99
+ When ` node ` , or one of its children, is not a valid mdast node.
100
+
101
+ ## Types
102
+
103
+ This package is fully typed with [ TypeScript] [ ] .
104
+ It does not export additional types.
105
+
106
+ ## Compatibility
107
+
108
+ Projects maintained by the unified collective are compatible with all maintained
109
+ versions of Node.js.
110
+ As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18.0+.
111
+ Our projects sometimes work with older versions, but this is not guaranteed.
54
112
55
113
## Security
56
114
@@ -68,8 +126,8 @@ The `parent`, `literal`, `_void`, and `wrap` methods from
68
126
69
127
## Contribute
70
128
71
- See [ ` contributing.md ` in ` syntax-tree/.github ` ] [ contributing ] for ways to get
72
- started.
129
+ See [ ` contributing.md ` ] [ contributing ] in [ ` syntax-tree/.github ` ] [ health ] for
130
+ ways to get started.
73
131
See [ ` support.md ` ] [ support ] for ways to get help.
74
132
75
133
This project has a [ code of conduct] [ coc ] .
@@ -110,15 +168,23 @@ abide by its terms.
110
168
111
169
[ npm ] : https://docs.npmjs.com/cli/install
112
170
171
+ [ esm ] : https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
172
+
173
+ [ esmsh ] : https://esm.sh
174
+
175
+ [ typescript ] : https://www.typescriptlang.org
176
+
113
177
[ license ] : license
114
178
115
179
[ author ] : https://wooorm.com
116
180
117
- [ contributing ] : https://github.com/syntax-tree/.github/blob/HEAD/contributing.md
181
+ [ health ] : https://github.com/syntax-tree/.github
182
+
183
+ [ contributing ] : https://github.com/syntax-tree/.github/blob/main/contributing.md
118
184
119
- [ support ] : https://github.com/syntax-tree/.github/blob/HEAD /support.md
185
+ [ support ] : https://github.com/syntax-tree/.github/blob/main /support.md
120
186
121
- [ coc ] : https://github.com/syntax-tree/.github/blob/HEAD /code-of-conduct.md
187
+ [ coc ] : https://github.com/syntax-tree/.github/blob/main /code-of-conduct.md
122
188
123
189
[ unist-util-assert ] : https://github.com/syntax-tree/unist-util-assert
124
190
@@ -128,6 +194,8 @@ abide by its terms.
128
194
129
195
[ child ] : https://github.com/syntax-tree/unist#child
130
196
197
+ [ unist ] : https://github.com/syntax-tree/unist
198
+
131
199
[ hast ] : https://github.com/syntax-tree/hast
132
200
133
201
[ xss ] : https://en.wikipedia.org/wiki/Cross-site_scripting
0 commit comments