Skip to content

Commit 7c39068

Browse files
committed
Add improved docs
1 parent 67e293e commit 7c39068

File tree

2 files changed

+68
-18
lines changed

2 files changed

+68
-18
lines changed

lib/index.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,24 @@
1919
* @property {number | null | undefined} [offset]
2020
*/
2121

22+
/**
23+
* Get the starting point of `node`.
24+
*
25+
* @param node
26+
* Node.
27+
* @returns
28+
* Point.
29+
*/
2230
export const pointStart = point('start')
31+
32+
/**
33+
* Get the ending point of `node`.
34+
*
35+
* @param node
36+
* Node.
37+
* @returns
38+
* Point.
39+
*/
2340
export const pointEnd = point('end')
2441

2542
/**

readme.md

Lines changed: 51 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
* [Install](#install)
1818
* [Use](#use)
1919
* [API](#api)
20-
* [`position(node?)`](#positionnode)
21-
* [`pointStart(node?)`](#pointstartnode)
22-
* [`pointEnd(node?)`](#pointendnode)
20+
* [`position(node)`](#positionnode)
21+
* [`pointEnd(node)`](#pointendnode)
22+
* [`pointStart(node)`](#pointstartnode)
2323
* [Types](#types)
2424
* [Compatibility](#compatibility)
2525
* [Related](#related)
@@ -48,7 +48,7 @@ to display positional info to users.
4848
## Install
4949

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

5353
```sh
5454
npm install unist-util-position
@@ -57,14 +57,14 @@ npm install unist-util-position
5757
In Deno with [`esm.sh`][esmsh]:
5858

5959
```js
60-
import {position, pointStart, pointEnd} from "https://esm.sh/unist-util-position@4"
60+
import {position, pointStart, pointEnd} from 'https://esm.sh/unist-util-position@4'
6161
```
6262

6363
In browsers with [`esm.sh`][esmsh]:
6464

6565
```html
6666
<script type="module">
67-
import {position, pointStart, pointEnd} from "https://esm.sh/unist-util-position@4?bundle"
67+
import {position, pointStart, pointEnd} from 'https://esm.sh/unist-util-position@4?bundle'
6868
</script>
6969
```
7070

@@ -90,21 +90,48 @@ Yields:
9090

9191
## API
9292

93-
This package exports the identifiers `position`, `pointStart`, and
94-
`pointEnd`.
93+
This package exports the identifiers [`pointEnd`][pointend],
94+
[`pointStart`][pointstart], and [`position`][position].
9595
There is no default export.
9696

97-
### `position(node?)`
97+
### `position(node)`
9898

99-
Get the positional info of `node` ([`Node?`][node]).
100-
Returns a proper [`Position`][position].
99+
Get the positional info of `node`.
101100

102-
### `pointStart(node?)`
101+
###### Parameters
103102

104-
### `pointEnd(node?)`
103+
* `node` ([`Node`][node])
104+
— node
105105

106-
Get the start or end points in the positional info of `node` ([`Node?`][node]).
107-
Returns a proper [`Point`][point].
106+
###### Returns
107+
108+
Position ([`Position`][unist-position]).
109+
110+
### `pointEnd(node)`
111+
112+
Get the ending point of `node`.
113+
114+
###### Parameters
115+
116+
* `node` ([`Node`][node])
117+
— node
118+
119+
###### Returns
120+
121+
Point ([`point`][unist-point]).
122+
123+
### `pointStart(node)`
124+
125+
Get the starting point of `node`.
126+
127+
###### Parameters
128+
129+
* `node` ([`Node`][node])
130+
— node
131+
132+
###### Returns
133+
134+
Point ([`point`][unist-point]).
108135

109136
## Types
110137

@@ -115,7 +142,7 @@ It exports no additional types.
115142

116143
Projects maintained by the unified collective are compatible with all maintained
117144
versions of Node.js.
118-
As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18.0+.
145+
As of now, that is Node.js 14.14+ and 16.0+.
119146
Our projects sometimes work with older versions, but this is not guaranteed.
120147

121148
## Related
@@ -197,10 +224,16 @@ abide by its terms.
197224

198225
[node]: https://github.com/syntax-tree/unist#node
199226

200-
[position]: https://github.com/syntax-tree/unist#position
227+
[unist-position]: https://github.com/syntax-tree/unist#position
201228

202-
[point]: https://github.com/syntax-tree/unist#point
229+
[unist-point]: https://github.com/syntax-tree/unist#point
203230

204231
[unist-util-generated]: https://github.com/syntax-tree/unist-util-generated
205232

206233
[unist-util-stringify-position]: https://github.com/syntax-tree/unist-util-stringify-position
234+
235+
[position]: #positionnode
236+
237+
[pointend]: #pointendnode
238+
239+
[pointstart]: #pointstartnode

0 commit comments

Comments
 (0)