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

index-to-position

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

index-to-position

Convert a string index to its line and column position


Version published
Weekly downloads
1.7M
increased by9.33%
Maintainers
1
Weekly downloads
 
Created
Issues
0

index-to-position

Convert a string index to its line and column position

Install

npm install index-to-position

Usage

import indexToPosition from 'index-to-position';

indexToPosition('hello\nworld\n!', 7);
//=> {line: 1, column: 1}

API

indexToPosition(text, index, options?)

text

Type: string

The text in which to find the line and column position.

index

Type: number

The index in the string for which to find the line and column position.

options

Type: object

oneBased

Type: boolean
Default: false

Whether to use 1-based or 0-based indexing for the result.

FAQs

Package last updated on 28 Feb 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