index-to-position
Convert a string index to its line and column position
Last updated a year ago by sindresorhus .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install index-to-position 
SYNC missed versions from official npm registry.

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.

Current Tags

  • 1.1.0                                ...           latest (a year ago)

5 Versions

  • 1.1.0                                ...           a year ago
  • 1.0.0                                ...           2 years ago
  • 0.1.2                                ...           2 years ago
  • 0.1.1                                ...           2 years ago
  • 0.1.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 1
This Month 1
Last Day 1
Last Week 0
Last Month 10
Dependencies (0)
None
Dev Dependencies (3)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |