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

vfile-location

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vfile-location

vfile utility to convert between positional (line and column-based) and offset (range-based) locations

  • 5.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.7M
decreased by-2.75%
Maintainers
1
Weekly downloads
 
Created

What is vfile-location?

The vfile-location npm package is a utility tool for working with virtual file objects, specifically designed to map positions in a virtual file to line and column-based locations. This is particularly useful when dealing with transformations or manipulations of text where tracking positions within the original and modified content is necessary.

What are vfile-location's main functionalities?

Location Mapping

This feature allows you to convert between line and column-based locations and absolute positions within a file's content. The `toOffset` method converts a line and column object to a zero-based offset, and the `toPoint` method converts an offset back to a line and column object.

const vfileLocation = require('vfile-location');
const text = 'Hello\nWorld';
const location = vfileLocation(text);

// Get position from line and column
const offset = location.toOffset({line: 2, column: 1}); // Returns 7

// Get line and column from position
const point = location.toPoint(offset); // Returns {line: 2, column: 1}

Other packages similar to vfile-location

Keywords

FAQs

Package last updated on 15 Jul 2024

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