@@ -10,61 +10,26 @@ Stringify a [**Unist**][unist] [position][] or [location][].
10
10
npm install unist-util-stringify-position
11
11
```
12
12
13
- ** unist-util-stringify-position** is also available as an AMD, CommonJS, and
14
- globals module, [ uncompressed and compressed] [ releases ] .
15
-
16
13
## Usage
17
14
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
-
38
15
``` 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'
68
33
```
69
34
70
35
## API
@@ -74,18 +39,18 @@ Yields:
74
39
Stringify one position, a location (start and end positions), or
75
40
a node’s location.
76
41
77
- ** Parameters** :
42
+ ###### Parameters
78
43
79
44
* ` node ` ([ ` Node ` ] [ node ] )
80
45
— Node whose ` 'position' ` property to stringify;
81
-
82
46
* ` location ` ([ ` Location ` ] [ location ] )
83
47
— Location whose ` 'start' ` and ` 'end' ` positions to stringify;
84
-
85
48
* ` position ` ([ ` Position ` ] [ position ] )
86
49
— Location whose ` 'line' ` and ` 'column' ` to stringify.
87
50
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
89
54
` location ` ) or a point ` l:c ` (when given ` position ` ), where ` l ` stands
90
55
for line, ` c ` for column, ` s ` for ` start ` , and ` e ` for
91
56
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`,
107
72
108
73
[ npm ] : https://docs.npmjs.com/cli/install
109
74
110
- [ releases ] : https://github.com/wooorm/unist-util-stringify-position/releases
111
-
112
75
[ license ] : LICENSE
113
76
114
77
[ author ] : http://wooorm.com
0 commit comments