.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / unist-util-stringify-position / readme.md
1 # unist-util-stringify-position [![Build Status][build-badge]][build-page] [![Coverage Status][coverage-badge]][coverage-page]
2
3 Stringify a [**Unist**][unist] [`Position`][position] or [`Point`][point].
4
5 ## Installation
6
7 [npm][]:
8
9 ```bash
10 npm install unist-util-stringify-position
11 ```
12
13 ## Usage
14
15 ```javascript
16 var stringify = require('unist-util-stringify-position')
17
18 // Point
19 stringify({line: 2, column: 3}) // => '2:3'
20
21 // Position
22 stringify({
23   start: {line: 2},
24   end: {line: 3}
25 }) // => '2:1-3:1'
26
27 // Node
28 stringify({
29   type: 'text',
30   value: '!',
31   position: {
32     start: {line: 5, column: 11},
33     end: {line: 5, column: 12}
34   }
35 }) // => '5:11-5:12'
36 ```
37
38 ## API
39
40 ### `stringifyPosition(node|position|point)`
41
42 Stringify one point, a position (start and end points), or
43 a node’s position.
44
45 ###### Parameters
46
47 *   `node` ([`Node`][node])
48     — Node whose `'position'` property to stringify
49 *   `position` ([`Position`][position])
50     — Position whose `'start'` and `'end'` points to stringify
51 *   `point` ([`Point`][point])
52     — Point whose `'line'` and `'column'` to stringify
53
54 ###### Returns
55
56 `string?` — A range `ls:cs-le:ce` (when given `node` or
57 `position`) or a point `l:c` (when given `point`), where `l` stands
58 for line, `c` for column, `s` for `start`, and `e` for
59 end.  `null` is returned if the given value is neither `node`,
60 `position`, nor `point`.
61
62 ## Contribute
63
64 See [`contributing.md` in `syntax-tree/unist`][contributing] for ways to get
65 started.
66
67 This organisation has a [Code of Conduct][coc].  By interacting with this
68 repository, organisation, or community you agree to abide by its terms.
69
70 ## License
71
72 [MIT][license] © [Titus Wormer][author]
73
74 <!-- Definition -->
75
76 [build-badge]: https://img.shields.io/travis/syntax-tree/unist-util-stringify-position.svg
77
78 [build-page]: https://travis-ci.org/syntax-tree/unist-util-stringify-position
79
80 [coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/unist-util-stringify-position.svg
81
82 [coverage-page]: https://codecov.io/github/syntax-tree/unist-util-stringify-position?branch=master
83
84 [npm]: https://docs.npmjs.com/cli/install
85
86 [license]: LICENSE
87
88 [author]: http://wooorm.com
89
90 [unist]: https://github.com/syntax-tree/unist
91
92 [node]: https://github.com/syntax-tree/unist#node
93
94 [position]: https://github.com/syntax-tree/unist#position
95
96 [point]: https://github.com/syntax-tree/unist#point
97
98 [contributing]: https://github.com/syntax-tree/unist/blob/master/contributing.md
99
100 [coc]: https://github.com/syntax-tree/unist/blob/master/code-of-conduct.md