17
17
* [ Install] ( #install )
18
18
* [ Use] ( #use )
19
19
* [ API] ( #api )
20
- * [ ` size(node [, test]) ` ] ( #sizenode -test )
20
+ * [ ` size(tree [, test]) ` ] ( #sizetree -test )
21
21
* [ Types] ( #types )
22
22
* [ Compatibility] ( #compatibility )
23
23
* [ Related] ( #related )
@@ -37,7 +37,7 @@ You can use [`unist-util-visit`][unist-util-visit] yourself as well.
37
37
## Install
38
38
39
39
This package is [ ESM only] [ esm ] .
40
- In Node.js (version 12.20+, 14.14+, 16.0+, 18 .0+), install with [ npm] [ ] :
40
+ In Node.js (version 14.14+ and 16 .0+), install with [ npm] [ ] :
41
41
42
42
``` sh
43
43
npm install unist-util-size
@@ -46,14 +46,14 @@ npm install unist-util-size
46
46
In Deno with [ ` esm.sh ` ] [ esmsh ] :
47
47
48
48
``` js
49
- import {size } from " https://esm.sh/unist-util-size@3"
49
+ import {size } from ' https://esm.sh/unist-util-size@3'
50
50
```
51
51
52
52
In browsers with [ ` esm.sh ` ] [ esmsh ] :
53
53
54
54
``` html
55
55
<script type =" module" >
56
- import {size } from " https://esm.sh/unist-util-size@3?bundle"
56
+ import {size } from ' https://esm.sh/unist-util-size@3?bundle'
57
57
</script >
58
58
```
59
59
@@ -80,17 +80,23 @@ console.log(size(tree, 'element')) // => 5
80
80
81
81
## API
82
82
83
- This package exports the identifier ` size ` .
83
+ This package exports the identifier [ ` size ` ] [ api-size ] .
84
84
There is no default export.
85
85
86
- ### ` size(node [, test]) `
86
+ ### ` size(tree [, test]) `
87
87
88
- Calculate the number of nodes in ` node ` ([ ` Node ` ] [ node ] ) that pass the optional
89
- ` unist-util-is ` -compatible [ ` Test ` ] [ test ] .
88
+ Calculate the number of nodes in ` tree ` .
90
89
91
- ##### Returns
90
+ ###### Parameters
92
91
93
- [ Exclusive descendants] [ descendant ] of ` node ` that pass ` test ` (` number ` ).
92
+ * ` tree ` ([ ` Node ` ] [ node ] )
93
+ — tree to traverse
94
+ * ` test ` ([ ` Test ` ] [ test ] )
95
+ — ` unist-util-is ` compatible test (such as a node type)
96
+
97
+ ###### Returns
98
+
99
+ Number of exclusive descendants of ` tree ` that pass ` test ` (` number ` ).
94
100
95
101
## Types
96
102
@@ -101,7 +107,7 @@ It exports no additional types.
101
107
102
108
Projects maintained by the unified collective are compatible with all maintained
103
109
versions of Node.js.
104
- As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18 .0+.
110
+ As of now, that is Node.js 14.14+ and 16 .0+.
105
111
Our projects sometimes work with older versions, but this is not guaranteed.
106
112
107
113
## Related
@@ -175,8 +181,8 @@ abide by its terms.
175
181
176
182
[ node ] : https://github.com/syntax-tree/unist#node
177
183
178
- [ descendant ] : https://github.com/syntax-tree/unist#descendant
179
-
180
184
[ unist-util-visit ] : https://github.com/syntax-tree/unist-util-visit
181
185
182
186
[ test ] : https://github.com/syntax-tree/unist-util-is#test
187
+
188
+ [ api-size ] : #sizetree-test
0 commit comments