Skip to content

Commit 477c820

Browse files
committed
Refactor docs
1 parent 8225be3 commit 477c820

File tree

1 file changed

+21
-58
lines changed

1 file changed

+21
-58
lines changed

readme.md

+21-58
Original file line numberDiff line numberDiff line change
@@ -10,61 +10,26 @@ Stringify a [**Unist**][unist] [position][] or [location][].
1010
npm install unist-util-stringify-position
1111
```
1212

13-
**unist-util-stringify-position** is also available as an AMD, CommonJS, and
14-
globals module, [uncompressed and compressed][releases].
15-
1613
## Usage
1714

18-
Dependencies:
19-
20-
```javascript
21-
var stringifyPosition = require('unist-util-stringify-position');
22-
```
23-
24-
Given a position:
25-
26-
```javascript
27-
var result = stringifyPosition({ 'line': 2, 'column': 3 });
28-
```
29-
30-
Yields:
31-
32-
```txt
33-
2:3
34-
```
35-
36-
Given a (partial) location:
37-
3815
```javascript
39-
result = stringifyPosition({
40-
'start': { 'line': 2 },
41-
'end': { 'line': 3 }
42-
});
43-
```
44-
45-
Yields:
46-
47-
```txt
48-
2:1-3:1
49-
```
50-
51-
Given a node:
52-
53-
```javascript
54-
result = stringifyPosition({
55-
'type': 'text',
56-
'value': '!',
57-
'position': {
58-
'start': { 'line': 5, 'column': 11 },
59-
'end': { 'line': 5, 'column': 12 }
60-
}
61-
});
62-
```
63-
64-
Yields:
65-
66-
```txt
67-
5:11-5:12
16+
var stringify = require('unist-util-stringify-position');
17+
18+
stringify({line: 2, column: 3 }); //=> '2:3'
19+
20+
stringify({
21+
start: {line: 2},
22+
end: {line: 3}
23+
}); //=> '2:1-3:1'
24+
25+
stringify({
26+
type: 'text',
27+
value: '!',
28+
position: {
29+
start: {line: 5, column: 11},
30+
end: {line: 5, column: 12}
31+
}
32+
}); //=> '5:11-5:12'
6833
```
6934

7035
## API
@@ -74,18 +39,18 @@ Yields:
7439
Stringify one position, a location (start and end positions), or
7540
a node’s location.
7641

77-
**Parameters**:
42+
###### Parameters
7843

7944
* `node` ([`Node`][node])
8045
— Node whose `'position'` property to stringify;
81-
8246
* `location` ([`Location`][location])
8347
— Location whose `'start'` and `'end'` positions to stringify;
84-
8548
* `position` ([`Position`][position])
8649
— Location whose `'line'` and `'column'` to stringify.
8750

88-
**Returns**: `string?` — A range `ls:cs-le:ce` (when given `node` or
51+
###### Returns
52+
53+
`string?` — A range `ls:cs-le:ce` (when given `node` or
8954
`location`) or a point `l:c` (when given `position`), where `l` stands
9055
for line, `c` for column, `s` for `start`, and `e` for
9156
end. `null` is returned if the given value is neither `node`,
@@ -107,8 +72,6 @@ end. `null` is returned if the given value is neither `node`,
10772

10873
[npm]: https://docs.npmjs.com/cli/install
10974

110-
[releases]: https://github.com/wooorm/unist-util-stringify-position/releases
111-
11275
[license]: LICENSE
11376

11477
[author]: http://wooorm.com

0 commit comments

Comments
 (0)