npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript.Learn more »

unist-util-position

3.0.3 • Public • Published

unist-util-position

Build Coverage Downloads Size Sponsors Backers Chat

unist utility to get the positional info of nodes.

Install

npm:

npm install unist-util-position

Usage

var remark = require('remark')
var position = require('unist-util-position')
 
var tree = remark().parse('# foo\n\n* bar\n')
 
position.start(tree) // => {line: 1, column: 1}
position.end(tree) // => {line: 4, column: 1}
 
position.start() // => {line: null, column: null}
position.end() // => {line: null, column: null}

API

position.start([node])

position.end([node])

Get the start or end points in the positional info of node.

Parameters
  • node (Node?) — Node to check.
Returns

Point — Filled with line (nullable uint32 >= 1), column (nullable uint32 >= 1), offset (nullable uint32 >= 0).

Note that in unist, line and column are 1-indexed integers and offset is a 0-indexed integer.

Contribute

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, organisation, or community you agree to abide by its terms.

License

MIT © Titus Wormer

install

npm i unist-util-position

Downloadsweekly downloads

242,200

version

3.0.3

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability