5
5
[ ![ Downloads] [ downloads-badge ]] [ downloads ]
6
6
[ ![ Size] [ size-badge ]] [ size ]
7
7
8
- [ ** Unist ** ] [ unist ] utility to find a node after another node.
8
+ [ ** unist ** ] [ unist ] utility to find a node after another node.
9
9
10
10
## Installation
11
11
12
12
[ npm] [ ] :
13
13
14
- ``` bash
14
+ ``` sh
15
15
npm install unist-util-find-after
16
16
```
17
17
18
18
## Usage
19
19
20
20
``` js
21
- var remark = require (' remark ' )
21
+ var u = require (' unist-builder ' )
22
22
var findAfter = require (' unist-util-find-after' )
23
23
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' ))
28
35
```
29
36
30
37
Yields:
31
38
32
39
``` js
33
- { type: ' strong' ,
34
- children: [ { type: ' text' , value: ' importance' } ] }
40
+ { type: ' node' , children: [ { type: ' leaf' , value: ' leaf 5' } ] }
35
41
```
36
42
37
43
## API
38
44
39
45
### ` findAfter(parent, node|index[, test]) `
40
46
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 ` .
43
49
44
50
###### Parameters
45
51
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)
50
56
— See [ ` unist-util-is ` ] [ is ]
51
57
52
58
###### Returns
53
59
54
- [ ` Node? ` ] [ node ] — Child node of ` parent ` passing ` test ` .
60
+ [ ` Node? ` ] [ node ] — [ Child] [ ] of ` parent ` passing ` test ` .
55
61
56
62
## Related
57
63
@@ -68,11 +74,13 @@ Find the first child after `index` (or `node`) in `parent`, that passes `test`
68
74
69
75
## Contribute
70
76
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
72
78
started.
79
+ See [ ` support.md ` ] [ support ] for ways to get help.
73
80
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.
76
84
77
85
## License
78
86
@@ -106,8 +114,16 @@ repository, organisation, or community you agree to abide by its terms.
106
114
107
115
[ node ] : https://github.com/syntax-tree/unist#node
108
116
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
+
109
123
[ is ] : https://github.com/syntax-tree/unist-util-is
110
124
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
112
128
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