Skip to content

Commit 850c945

Browse files
committed
Add improved docs
1 parent 966615a commit 850c945

File tree

2 files changed

+25
-19
lines changed

2 files changed

+25
-19
lines changed

lib/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ import {convert} from 'unist-util-is'
99
let empty
1010

1111
/**
12-
* Calculate the number of nodes in `node`.
12+
* Calculate the number of nodes in `tree`.
1313
*
14-
* @param {Node} node
14+
* @param {Node} tree
1515
* Tree to traverse.
1616
* @param {Test} [test]
17-
* `unist-util-is`-compatible test (such as a node type).
17+
* `unist-util-is` compatible test (such as a node type).
1818
* @returns {number}
19-
* Exclusive descendants of `node` that pass `test`.
19+
* Number of exclusive descendants of `tree` that pass `test`.
2020
*/
21-
export function size(node, test) {
21+
export function size(tree, test) {
2222
const is = convert(test)
2323

24-
return fastSize(node)
24+
return fastSize(tree)
2525

2626
/**
2727
* @param {Node} node

readme.md

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* [Install](#install)
1818
* [Use](#use)
1919
* [API](#api)
20-
* [`size(node[, test])`](#sizenode-test)
20+
* [`size(tree[, test])`](#sizetree-test)
2121
* [Types](#types)
2222
* [Compatibility](#compatibility)
2323
* [Related](#related)
@@ -37,7 +37,7 @@ You can use [`unist-util-visit`][unist-util-visit] yourself as well.
3737
## Install
3838

3939
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][]:
4141

4242
```sh
4343
npm install unist-util-size
@@ -46,14 +46,14 @@ npm install unist-util-size
4646
In Deno with [`esm.sh`][esmsh]:
4747

4848
```js
49-
import {size} from "https://esm.sh/unist-util-size@3"
49+
import {size} from 'https://esm.sh/unist-util-size@3'
5050
```
5151

5252
In browsers with [`esm.sh`][esmsh]:
5353

5454
```html
5555
<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'
5757
</script>
5858
```
5959

@@ -80,17 +80,23 @@ console.log(size(tree, 'element')) // => 5
8080

8181
## API
8282

83-
This package exports the identifier `size`.
83+
This package exports the identifier [`size`][api-size].
8484
There is no default export.
8585

86-
### `size(node[, test])`
86+
### `size(tree[, test])`
8787

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`.
9089

91-
##### Returns
90+
###### Parameters
9291

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`).
94100

95101
## Types
96102

@@ -101,7 +107,7 @@ It exports no additional types.
101107

102108
Projects maintained by the unified collective are compatible with all maintained
103109
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+.
105111
Our projects sometimes work with older versions, but this is not guaranteed.
106112

107113
## Related
@@ -175,8 +181,8 @@ abide by its terms.
175181

176182
[node]: https://github.com/syntax-tree/unist#node
177183

178-
[descendant]: https://github.com/syntax-tree/unist#descendant
179-
180184
[unist-util-visit]: https://github.com/syntax-tree/unist-util-visit
181185

182186
[test]: https://github.com/syntax-tree/unist-util-is#test
187+
188+
[api-size]: #sizetree-test

0 commit comments

Comments
 (0)