88[ ![ Backers] [ backers-badge ]] [ collective ]
99[ ![ Chat] [ chat-badge ]] [ chat ]
1010
11- [ ** unist** ] [ unist ] utility to pretty print the positional information of a node.
11+ ** [ unist] [ ] ** utility to pretty print the positional information of a node.
1212
13- ## Install
13+ ## Contents
14+
15+ * [ What is this?] ( #what-is-this )
16+ * [ When should I use this?] ( #when-should-i-use-this )
17+ * [ Install] ( #install )
18+ * [ Use] ( #use )
19+ * [ API] ( #api )
20+ * [ ` stringifyPosition(node|position|point) ` ] ( #stringifypositionnodepositionpoint )
21+ * [ Types] ( #types )
22+ * [ Compatibility] ( #compatibility )
23+ * [ Security] ( #security )
24+ * [ Related] ( #related )
25+ * [ Contribute] ( #contribute )
26+ * [ License] ( #license )
27+
28+ ## What is this?
29+
30+ This package is a utility that takes any [ unist] [ ] (whether mdast, hast, etc)
31+ node, position, or point, and serializes its positional info.
1432
15- This package is [ ESM only] ( https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c ) :
16- Node 12+ is needed to use it and it must be ` import ` ed instead of ` require ` d.
33+ ## When should I use this?
34+
35+ This utility is useful to display where something occurred in the original
36+ document, in one standard way, for humans.
37+ For example, when throwing errors or warning messages about something.
38+
39+ ## Install
1740
18- [ npm] [ ] :
41+ This package is [ ESM only] [ esm ] .
42+ In Node.js (version 12.20+, 14.14+, or 16.0+), install with [ npm] [ ] :
1943
2044``` sh
2145npm install unist-util-stringify-position
2246```
2347
24- ## Use
48+ In Deno with [ ` esm.sh ` ] [ esmsh ] :
2549
2650``` js
27- import {stringifyPosition } from ' unist-util-stringify-position'
51+ import {stringifyPosition } from ' https://esm.sh/unist-util-stringify-position@3'
52+ ```
53+
54+ In browsers with [ ` esm.sh ` ] [ esmsh ] :
55+
56+ ``` html
57+ <script type =" module" >
58+ import {stringifyPosition } from ' https://esm.sh/unist-util-stringify-position@3?bundle'
59+ </script >
60+ ```
2861
29- // Point
30- stringifyPosition ({line: 2 , column: 3 }) // => '2:3'
62+ ## Use
3163
32- // Position
33- stringifyPosition ({start : {line : 2 }, end : {line : 3 }}) // => '2:1-3:1 '
64+ ``` js
65+ import { stringifyPosition } from ' unist-util-stringify-position '
3466
35- // Node
67+ stringifyPosition ({line: 2 , column: 3 }) // => '2:3' (point)
68+ stringifyPosition ({start: {line: 2 }, end: {line: 3 }}) // => '2:1-3:1' (position)
3669stringifyPosition ({
3770 type: ' text' ,
3871 value: ' !' ,
3972 position: {
4073 start: {line: 5 , column: 11 },
4174 end: {line: 5 , column: 12 }
4275 }
43- }) // => '5:11-5:12'
76+ }) // => '5:11-5:12' (node)
4477```
4578
4679## API
4780
48- This package exports the following identifiers: ` stringifyPosition ` .
81+ This package exports the identifier ` stringifyPosition ` .
4982There is no default export.
5083
5184### ` stringifyPosition(node|position|point) `
5285
53- Stringify one [ point] [ ] , a [ position] [ ] (start and end [ point] [ ] s), or a node’s
54- [ positional information] [ positional-information ] .
86+ Stringify a [ point] [ ] , [ position] [ ] , or a [ node] [ ] .
5587
5688###### Parameters
5789
5890* ` node ` ([ ` Node ` ] [ node ] )
59- — Node whose ` 'position' ` property to stringify
91+ — node whose ` 'position' ` property to stringify
6092* ` position ` ([ ` Position ` ] [ position ] )
61- — Position whose ` 'start' ` and ` 'end' ` points to stringify
93+ — position whose ` 'start' ` and ` 'end' ` points to stringify
6294* ` point ` ([ ` Point ` ] [ point ] )
63- — Point whose ` 'line' ` and ` 'column' ` to stringify
95+ — point whose ` 'line' ` and ` 'column' ` to stringify
6496
6597###### Returns
6698
@@ -70,16 +102,32 @@ Stringify one [point][], a [position][] (start and end [point][]s), or a node’
70102An empty string (` '' ` ) is returned if the given value is neither ` node ` ,
71103` position ` , nor ` point ` .
72104
105+ ## Types
106+
107+ This package is fully typed with [ TypeScript] [ ] .
108+ There are no additional types exported.
109+
110+ ## Compatibility
111+
112+ Projects maintained by the unified collective are compatible with all maintained
113+ versions of Node.js.
114+ As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
115+ Our projects sometimes work with older versions, but this is not guaranteed.
116+
117+ ## Security
118+
119+ This project is safe.
120+
73121## Related
74122
75123* [ ` unist-util-generated ` ] ( https://github.com/syntax-tree/unist-util-generated )
76- — Check if a node is generated
124+ — check if a node is generated
77125* [ ` unist-util-position ` ] ( https://github.com/syntax-tree/unist-util-position )
78- — Get positional info of nodes
126+ — get positional info of nodes
79127* [ ` unist-util-remove-position ` ] ( https://github.com/syntax-tree/unist-util-remove-position )
80- — Remove positional info from trees
128+ — remove positional info from trees
81129* [ ` unist-util-source ` ] ( https://github.com/syntax-tree/unist-util-source )
82- — Get the source of a value (node or position) in a file
130+ — get the source of a value (node or position) in a file
83131
84132## Contribute
85133
@@ -129,6 +177,12 @@ abide by its terms.
129177
130178[ author ] : https://wooorm.com
131179
180+ [ esm ] : https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
181+
182+ [ esmsh ] : https://esm.sh
183+
184+ [ typescript ] : https://www.typescriptlang.org
185+
132186[ contributing ] : https://github.com/syntax-tree/.github/blob/HEAD/contributing.md
133187
134188[ support ] : https://github.com/syntax-tree/.github/blob/HEAD/support.md
@@ -142,5 +196,3 @@ abide by its terms.
142196[ position ] : https://github.com/syntax-tree/unist#position
143197
144198[ point ] : https://github.com/syntax-tree/unist#point
145-
146- [ positional-information ] : https://github.com/syntax-tree/unist#positional-information
0 commit comments