@@ -48,7 +48,7 @@ of parents.
4848## Install
4949
5050This package is [ ESM only] [ esm ] .
51- In Node.js (version 14.14+ and 16.0 +), install with [ npm] [ ] :
51+ In Node.js (version 16 +), install with [ npm] [ ] :
5252
5353``` sh
5454npm install unist-util-visit
@@ -57,41 +57,39 @@ npm install unist-util-visit
5757In Deno with [ ` esm.sh ` ] [ esmsh ] :
5858
5959``` js
60- import {visit } from ' https://esm.sh/unist-util-visit@4'
60+ import {CONTINUE , EXIT , SKIP , visit } from ' https://esm.sh/unist-util-visit@4'
6161```
6262
6363In browsers with [ ` esm.sh ` ] [ esmsh ] :
6464
6565``` html
6666<script type =" module" >
67- import {visit } from ' https://esm.sh/unist-util-visit@4?bundle'
67+ import {CONTINUE , EXIT , SKIP , visit } from ' https://esm.sh/unist-util-visit@4?bundle'
6868 </script >
6969```
7070
7171## Use
7272
7373``` js
74- import {u } from ' unist-builder '
74+ import {fromMarkdown } from ' mdast-util-from-markdown '
7575import {visit } from ' unist-util-visit'
7676
77- const tree = u (' tree' , [
78- u (' leaf' , ' 1' ),
79- u (' node' , [u (' leaf' , ' 2' )]),
80- u (' void' ),
81- u (' leaf' , ' 3' )
82- ])
77+ const tree = fromMarkdown (' Some *emphasis*, **strong**, and `code`.' )
8378
84- visit (tree, ' leaf ' , function (node ) {
85- console .log (node)
79+ visit (tree, ' text ' , function (node , index , parent ) {
80+ console .log ([ node . value , parent ? parent . type : index] )
8681})
8782```
8883
8984Yields:
9085
9186``` js
92- {type: ' leaf' , value: ' 1' }
93- {type: ' leaf' , value: ' 2' }
94- {type: ' leaf' , value: ' 3' }
87+ [ ' Some ' , ' paragraph' ]
88+ [ ' emphasis' , ' emphasis' ]
89+ [ ' , ' , ' paragraph' ]
90+ [ ' strong' , ' strong' ]
91+ [ ' , and ' , ' paragraph' ]
92+ [ ' .' , ' paragraph' ]
9593```
9694
9795## API
@@ -125,12 +123,12 @@ See [`Action` in `unist-util-visit-parents`][vp-action].
125123### ` ActionTuple `
126124
127125List with an action and an index (TypeScript type).
128- See [ ` ActionTuple ` in ` unist-util-visit-parents ` ] [ vp-actiontuple ] .
126+ See [ ` ActionTuple ` in ` unist-util-visit-parents ` ] [ vp-action-tuple ] .
129127
130128### ` BuildVisitor `
131129
132130Build a typed ` Visitor ` function from a tree and a test (TypeScript type).
133- See [ ` BuildVisitor ` in ` unist-util-visit-parents ` ] [ vp-buildvisitor ] .
131+ See [ ` BuildVisitor ` in ` unist-util-visit-parents ` ] [ vp-build-visitor ] .
134132
135133### ` Index `
136134
@@ -183,22 +181,25 @@ When the `Action` is `CONTINUE`, `Index` can be returned.
183181### ` VisitorResult `
184182
185183Any value that can be returned from a visitor (TypeScript type).
186- See [ ` VisitorResult ` in ` unist-util-visit-parents ` ] [ vp-visitorresult ] .
184+ See [ ` VisitorResult ` in ` unist-util-visit-parents ` ] [ vp-visitor-result ] .
187185
188186## Types
189187
190188This package is fully typed with [ TypeScript] [ ] .
191189It exports the additional types [ ` Action ` ] [ api-action ] ,
192- [ ` ActionTuple ` ] [ api-actiontuple ] , [ ` BuildVisitor ` ] [ api-buildvisitor ] ,
190+ [ ` ActionTuple ` ] [ api-action-tuple ] , [ ` BuildVisitor ` ] [ api-build-visitor ] ,
193191[ ` Index ` ] [ api-index ] , [ ` Test ` ] [ api-test ] , [ ` Visitor ` ] [ api-visitor ] , and
194- [ ` VisitorResult ` ] [ api-visitorresult ] .
192+ [ ` VisitorResult ` ] [ api-visitor-result ] .
195193
196194## Compatibility
197195
198- Projects maintained by the unified collective are compatible with all maintained
196+ Projects maintained by the unified collective are compatible with maintained
199197versions of Node.js.
200- As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18.0+.
201- Our projects sometimes work with older versions, but this is not guaranteed.
198+
199+ When we cut a new major release, we drop support for unmaintained versions of
200+ Node.
201+ This means we try to keep the current release line, ` unist-util-visit@^4 ` ,
202+ compatible with Node.js 12.
202203
203204## Related
204205
@@ -243,9 +244,9 @@ abide by its terms.
243244
244245[ downloads ] : https://www.npmjs.com/package/unist-util-visit
245246
246- [ size-badge ] : https://img.shields.io/bundlephobia/minzip/ unist-util-visit.svg
247+ [ size-badge ] : https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q= unist-util-visit
247248
248- [ size ] : https://bundlephobia .com/result?p =unist-util-visit
249+ [ size ] : https://bundlejs .com/?q =unist-util-visit
249250
250251[ sponsors-badge ] : https://opencollective.com/unified/sponsors/badge.svg
251252
@@ -287,13 +288,13 @@ abide by its terms.
287288
288289[ vp-action ] : https://github.com/syntax-tree/unist-util-visit-parents#action
289290
290- [ vp-actiontuple ] : https://github.com/syntax-tree/unist-util-visit-parents#actiontuple
291+ [ vp-action-tuple ] : https://github.com/syntax-tree/unist-util-visit-parents#actiontuple
291292
292- [ vp-buildvisitor ] : https://github.com/syntax-tree/unist-util-visit-parents#buildvisitor
293+ [ vp-build-visitor ] : https://github.com/syntax-tree/unist-util-visit-parents#buildvisitor
293294
294295[ vp-index ] : https://github.com/syntax-tree/unist-util-visit-parents#index
295296
296- [ vp-visitorresult ] : https://github.com/syntax-tree/unist-util-visit-parents#visitorresult
297+ [ vp-visitor-result ] : https://github.com/syntax-tree/unist-util-visit-parents#visitorresult
297298
298299[ api-visit ] : #visittree-test-visitor-reverse
299300
@@ -305,14 +306,14 @@ abide by its terms.
305306
306307[ api-action ] : #action
307308
308- [ api-actiontuple ] : #actiontuple
309+ [ api-action-tuple ] : #actiontuple
309310
310- [ api-buildvisitor ] : #buildvisitor
311+ [ api-build-visitor ] : #buildvisitor
311312
312313[ api-index ] : #index
313314
314315[ api-test ] : #test
315316
316317[ api-visitor ] : #visitor
317318
318- [ api-visitorresult ] : #visitorresult
319+ [ api-visitor-result ] : #visitorresult
0 commit comments