Project: syntax-tree/unist-util-stringify-position

Package: unist-util-stringify-position@3.0.0

  1. Dependencies: 0·Dependents: 21
  2. unist utility to serialize a node, position, or point as a human readable location
  1. util 128
  2. utility 124
  3. unist 120
  4. unist-util 25
  5. node 23
  6. stringify 18
  7. position 9
  8. location 4
  9. point 3
  10. tostring 2


Build Coverage Downloads Size Sponsors Backers Chat

unist utility to pretty print the positional information of a node.


This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required.


npm install unist-util-stringify-position


import {stringifyPosition} from 'unist-util-stringify-position'

// Point
stringifyPosition({line: 2, column: 3}) // => '2:3'

// Position
stringifyPosition({start: {line: 2}, end: {line: 3}}) // => '2:1-3:1'

// Node
  type: 'text',
  value: '!',
  position: {
    start: {line: 5, column: 11},
    end: {line: 5, column: 12}
}) // => '5:11-5:12'


This package exports the following identifiers: stringifyPosition. There is no default export.


Stringify one point, a position (start and end points), or a node’s positional information.


string? — A range ls:cs-le:ce (when given node or position) or a point l:c (when given point), where l stands for line, c for column, s for start, and e for end. An empty string ('') is returned if the given value is neither node, position, nor point.


See contributing.md in syntax-tree/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.


MIT © Titus Wormer