Skip to content

Commit 322e6d1

Browse files
committed
Add improved docs
1 parent 2fae894 commit 322e6d1

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

readme.md

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ But this helps when integrating with the rest of unified and unist.
3838
## Install
3939

4040
This package is [ESM only][esm].
41-
In Node.js (version 12.20+, 14.14+, 16.0+, 18.0+), install with [npm][]:
41+
In Node.js (version 14.14+ and 16.0+), install with [npm][]:
4242

4343
```sh
4444
npm install unist-util-find-before
@@ -47,14 +47,14 @@ npm install unist-util-find-before
4747
In Deno with [`esm.sh`][esmsh]:
4848

4949
```js
50-
import {findBefore} from "https://esm.sh/unist-util-find-before@3"
50+
import {findBefore} from 'https://esm.sh/unist-util-find-before@3'
5151
```
5252

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

5555
```html
5656
<script type="module">
57-
import {findBefore} from "https://esm.sh/unist-util-find-before@3?bundle"
57+
import {findBefore} from 'https://esm.sh/unist-util-find-before@3?bundle'
5858
</script>
5959
```
6060

@@ -87,18 +87,28 @@ Yields:
8787

8888
## API
8989

90-
This package exports the identifier `findBefore`.
90+
This package exports the identifier [`findBefore`][api-findbefore].
9191
There is no default export.
9292

9393
### `findBefore(parent, node|index[, test])`
9494

95-
Find the first node in `parent` ([`Parent`][parent]) before another `node`
96-
([`Node`][node]) or before an index, that passes `test` (`Test` from
97-
[`unist-util-is`][test]).
95+
Find the first node in `parent` before another `node` or before an index,
96+
that passes `test`.
97+
98+
###### Parameters
99+
100+
* `parent` ([`Node`][node])
101+
— parent node
102+
* `index` (`number`)
103+
— index of child in `parent`
104+
* `child` ([`Node`][node])
105+
— child in `parent`
106+
* `test` ([`Test`][test])
107+
`unist-util-is`-compatible test
98108

99109
###### Returns
100110

101-
Child of `parent` that passes `test`, if found ([`Node?`][node]).
111+
Child of `parent` ([`Node`][node]) or `null`.
102112

103113
## Types
104114

@@ -109,7 +119,7 @@ It exports no additional types (types for the test are in `unist-util-is`).
109119

110120
Projects maintained by the unified collective are compatible with all maintained
111121
versions of Node.js.
112-
As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18.0+.
122+
As of now, that is Node.js 14.14+ and 16.0+.
113123
Our projects sometimes work with older versions, but this is not guaranteed.
114124

115125
## Related
@@ -203,6 +213,6 @@ abide by its terms.
203213

204214
[node]: https://github.com/syntax-tree/unist#node
205215

206-
[parent]: https://github.com/syntax-tree/unist#parent-1
207-
208216
[test]: https://github.com/syntax-tree/unist-util-is#test
217+
218+
[api-findbefore]: #findbeforeparent-nodeindex-test

0 commit comments

Comments
 (0)