55[ ![ Downloads] [ downloads-badge ]] [ downloads ]
66[ ![ Size] [ size-badge ]] [ size ]
77
8- [ ** Unist ** ] [ unist ] utility to find a node after another node.
8+ [ ** unist ** ] [ unist ] utility to find a node after another node.
99
1010## Installation
1111
1212[ npm] [ ] :
1313
14- ``` bash
14+ ``` sh
1515npm install unist-util-find-after
1616```
1717
1818## Usage
1919
2020``` js
21- var remark = require (' remark ' )
21+ var u = require (' unist-builder ' )
2222var findAfter = require (' unist-util-find-after' )
2323
24- var tree = remark ().parse (' Some _emphasis_, **importance**, and `code`.' )
25- var paragraph = tree .children [0 ]
26-
27- console .log (findAfter (paragraph, 1 , ' strong' ))
24+ var tree = u (' tree' , [
25+ u (' leaf' , ' leaf 1' ),
26+ u (' node' , [u (' leaf' , ' leaf 2' ), u (' leaf' , ' leaf 3' )]),
27+ u (' leaf' , ' leaf 4' ),
28+ u (' node' , [u (' leaf' , ' leaf 5' )]),
29+ u (' leaf' , ' leaf 6' ),
30+ u (' void' ),
31+ u (' leaf' , ' leaf 7' )
32+ ])
33+
34+ console .log (findAfter (tree, 1 , ' node' ))
2835```
2936
3037Yields:
3138
3239``` js
33- { type: ' strong' ,
34- children: [ { type: ' text' , value: ' importance' } ] }
40+ { type: ' node' , children: [ { type: ' leaf' , value: ' leaf 5' } ] }
3541```
3642
3743## API
3844
3945### ` findAfter(parent, node|index[, test]) `
4046
41- Find the first child after ` index ` (or ` node ` ) in ` parent ` , that passes ` test `
42- (when given) .
47+ Find the first [ child] [ ] after ` index ` (or ` node ` ) in ` parent ` , that passes
48+ ` test ` .
4349
4450###### Parameters
4551
46- * ` parent ` ([ ` Node ` ] [ node ] ) — Context node
47- * ` node ` ([ ` Node ` ] [ node ] ) — Node in ` parent `
48- * ` index ` (` number ` , optional) — Position of a ` node ` in ` parent `
49- * ` test ` (` Function ` , ` string ` , or ` Node ` , optional)
52+ * ` parent ` ([ ` Node ` ] [ node ] ) — [ Parent ] [ ] node
53+ * ` node ` ([ ` Node ` ] [ node ] ) — [ Child ] [ ] of ` parent `
54+ * ` index ` (` number ` , optional) — [ Index ] [ ] in ` parent `
55+ * ` test ` (` Function ` , ` string ` , ` Object ` , ` Array ` , optional)
5056 — See [ ` unist-util-is ` ] [ is ]
5157
5258###### Returns
5359
54- [ ` Node? ` ] [ node ] — Child node of ` parent ` passing ` test ` .
60+ [ ` Node? ` ] [ node ] — [ Child] [ ] of ` parent ` passing ` test ` .
5561
5662## Related
5763
@@ -68,11 +74,13 @@ Find the first child after `index` (or `node`) in `parent`, that passes `test`
6874
6975## Contribute
7076
71- See [ ` contributing.md ` in ` syntax-tree/unist ` ] [ contributing ] for ways to get
77+ See [ ` contributing.md ` in ` syntax-tree/.github ` ] [ contributing ] for ways to get
7278started.
79+ See [ ` support.md ` ] [ support ] for ways to get help.
7380
74- This organisation has a [ Code of Conduct] [ coc ] . By interacting with this
75- repository, organisation, or community you agree to abide by its terms.
81+ This project has a [ Code of Conduct] [ coc ] .
82+ By interacting with this repository, organisation, or community you agree to
83+ abide by its terms.
7684
7785## License
7886
@@ -106,8 +114,16 @@ repository, organisation, or community you agree to abide by its terms.
106114
107115[ node ] : https://github.com/syntax-tree/unist#node
108116
117+ [ parent ] : https://github.com/syntax-tree/unist#parent-1
118+
119+ [ child ] : https://github.com/syntax-tree/unist#child
120+
121+ [ index ] : https://github.com/syntax-tree/unist#index
122+
109123[ is ] : https://github.com/syntax-tree/unist-util-is
110124
111- [ contributing ] : https://github.com/syntax-tree/unist/blob/master/contributing.md
125+ [ contributing ] : https://github.com/syntax-tree/.github/blob/master/contributing.md
126+
127+ [ support ] : https://github.com/syntax-tree/.github/blob/master/support.md
112128
113- [ coc ] : https://github.com/syntax-tree/unist /blob/master/code-of-conduct.md
129+ [ coc ] : https://github.com/syntax-tree/.github /blob/master/code-of-conduct.md
0 commit comments