1818* [ Use] ( #use )
1919* [ API] ( #api )
2020 * [ ` remove(tree[, options], test) ` ] ( #removetree-options-test )
21+ * [ ` Options ` ] ( #options )
2122* [ Types] ( #types )
2223* [ Compatibility] ( #compatibility )
2324* [ Related] ( #related )
@@ -43,7 +44,7 @@ To create trees, use [`unist-builder`][unist-builder].
4344## Install
4445
4546This 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] [ ] :
4748
4849``` sh
4950npm install unist-util-remove
@@ -52,14 +53,14 @@ npm install unist-util-remove
5253In Deno with [ ` esm.sh ` ] [ esmsh ] :
5354
5455``` js
55- import {remove } from " https://esm.sh/unist-util-remove@3"
56+ import {remove } from ' https://esm.sh/unist-util-remove@3'
5657```
5758
5859In browsers with [ ` esm.sh ` ] [ esmsh ] :
5960
6061``` html
6162<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'
6364 </script >
6465```
6566
@@ -104,34 +105,45 @@ Yields:
104105
105106## API
106107
107- This package exports the identifier ` remove ` .
108+ This package exports the identifier [ ` remove ` ] [ api-remove ] .
108109There is no default export.
109110
110111### ` remove(tree[, options], test) `
111112
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 ` .
116114
117- ##### ` options `
115+ The tree is walked in * [ preorder] [ ] * (NLR), visiting the node itself, then its
116+ head, etc.
118117
119- Configuration (optional).
118+ ###### Parameters
120119
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
122126
123- Whether to drop parent nodes if they had children, but all their children were
124- filtered out (` boolean ` , default: ` true ` ).
127+ ###### Returns
125128
126- ##### Returns
129+ A changed given ` tree ` , without nodes that pass ` test ` .
127130
128- The given ` tree ` without nodes that pass ` test ` ([ ` Node? ` ] [ node ] ).
129131` null ` is returned if ` tree ` itself didn’t pass the test or is cascaded away.
130132
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+
131143## Types
132144
133145This package is fully typed with [ TypeScript] [ ] .
134- It exports no additional types .
146+ It exports the additional type [ ` Options ` ] [ api-options ] .
135147
136148## Compatibility
137149
@@ -228,3 +240,7 @@ abide by its terms.
228240[ unist-util-visit ] : https://github.com/syntax-tree/unist-util-visit
229241
230242[ unist-builder ] : https://github.com/syntax-tree/unist-builder
243+
244+ [ api-remove ] : #removetree-options-test
245+
246+ [ api-options ] : #options
0 commit comments