18
18
* [ Use] ( #use )
19
19
* [ API] ( #api )
20
20
* [ ` remove(tree[, options], test) ` ] ( #removetree-options-test )
21
+ * [ ` Options ` ] ( #options )
21
22
* [ Types] ( #types )
22
23
* [ Compatibility] ( #compatibility )
23
24
* [ Related] ( #related )
@@ -43,7 +44,7 @@ To create trees, use [`unist-builder`][unist-builder].
43
44
## Install
44
45
45
46
This package is [ ESM only] [ esm ] .
46
- In Node.js (version 12.20+, 14.14+, 16.0+, 18 .0+), install with [ npm] [ ] :
47
+ In Node.js (version 14.14+ and 16 .0+), install with [ npm] [ ] :
47
48
48
49
``` sh
49
50
npm install unist-util-remove
@@ -52,14 +53,14 @@ npm install unist-util-remove
52
53
In Deno with [ ` esm.sh ` ] [ esmsh ] :
53
54
54
55
``` js
55
- import {remove } from " https://esm.sh/unist-util-remove@3"
56
+ import {remove } from ' https://esm.sh/unist-util-remove@3'
56
57
```
57
58
58
59
In browsers with [ ` esm.sh ` ] [ esmsh ] :
59
60
60
61
``` html
61
62
<script type =" module" >
62
- import {remove } from " https://esm.sh/unist-util-remove@3?bundle"
63
+ import {remove } from ' https://esm.sh/unist-util-remove@3?bundle'
63
64
</script >
64
65
```
65
66
@@ -104,34 +105,45 @@ Yields:
104
105
105
106
## API
106
107
107
- This package exports the identifier ` remove ` .
108
+ This package exports the identifier [ ` remove ` ] [ api-remove ] .
108
109
There is no default export.
109
110
110
111
### ` remove(tree[, options], test) `
111
112
112
- Mutate the given ` tree ` ([ ` Node ` ] [ node ] ) by removing all nodes that pass ` test `
113
- (` Test ` from [ ` unist-util-is ` ] [ test ] ).
114
- The tree is walked in [ preorder] [ ] (NLR), visiting the node itself, then its
115
- head, etc.
113
+ Change the given ` tree ` by removing all nodes that pass ` test ` .
116
114
117
- ##### ` options `
115
+ The tree is walked in * [ preorder] [ ] * (NLR), visiting the node itself, then its
116
+ head, etc.
118
117
119
- Configuration (optional).
118
+ ###### Parameters
120
119
121
- ###### ` options.cascade `
120
+ * ` tree ` ([ ` Node ` ] [ node ] )
121
+ — tree to change
122
+ * ` options ` ([ ` Options ` ] [ api-options ] , optional)
123
+ — configuration
124
+ * ` test ` ([ ` Test ` ] [ test ] , optional)
125
+ — ` unist-util-is ` compatible test
122
126
123
- Whether to drop parent nodes if they had children, but all their children were
124
- filtered out (` boolean ` , default: ` true ` ).
127
+ ###### Returns
125
128
126
- ##### Returns
129
+ A changed given ` tree ` , without nodes that pass ` test ` .
127
130
128
- The given ` tree ` without nodes that pass ` test ` ([ ` Node? ` ] [ node ] ).
129
131
` null ` is returned if ` tree ` itself didn’t pass the test or is cascaded away.
130
132
133
+ ### ` Options `
134
+
135
+ Configuration (TypeScript type).
136
+
137
+ ###### Fields
138
+
139
+ * ` cascade ` (` boolean ` , default: ` true ` )
140
+ — whether to drop parent nodes if they had children, but all their children
141
+ were filtered out
142
+
131
143
## Types
132
144
133
145
This package is fully typed with [ TypeScript] [ ] .
134
- It exports no additional types .
146
+ It exports the additional type [ ` Options ` ] [ api-options ] .
135
147
136
148
## Compatibility
137
149
@@ -228,3 +240,7 @@ abide by its terms.
228
240
[ unist-util-visit ] : https://github.com/syntax-tree/unist-util-visit
229
241
230
242
[ unist-builder ] : https://github.com/syntax-tree/unist-builder
243
+
244
+ [ api-remove ] : #removetree-options-test
245
+
246
+ [ api-options ] : #options
0 commit comments