Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

unist-util-position

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unist-util-position

Utility to get the position of unist nodes

  • 3.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6.8M
increased by5.19%
Maintainers
1
Weekly downloads
 
Created

What is unist-util-position?

The unist-util-position package is a utility for working with positional information in unist syntax trees. It provides functions to get and manipulate positions of nodes within these trees, which is useful for tasks such as error reporting, syntax highlighting, and more.

What are unist-util-position's main functionalities?

position.start

This feature retrieves the starting position of a node. The code sample demonstrates how to use the `position.start` function to get the starting line and column of a node.

const position = require('unist-util-position');
const node = { position: { start: { line: 1, column: 1 }, end: { line: 1, column: 5 } } };
console.log(position.start(node)); // { line: 1, column: 1 }

position.end

This feature retrieves the ending position of a node. The code sample shows how to use the `position.end` function to get the ending line and column of a node.

const position = require('unist-util-position');
const node = { position: { start: { line: 1, column: 1 }, end: { line: 1, column: 5 } } };
console.log(position.end(node)); // { line: 1, column: 5 }

position.point

This feature normalizes a point object. The code sample demonstrates how to use the `position.point` function to ensure a point object has the correct structure.

const position = require('unist-util-position');
const point = { line: 1, column: 1 };
console.log(position.point(point)); // { line: 1, column: 1 }

Other packages similar to unist-util-position

Keywords

FAQs

Package last updated on 22 May 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc