linecol2index
v1.0.3
Published
Maps a line and column number to the index position of a given string
Downloads
4
Maintainers
Readme
linecol2index
Maps a line and column number to the index position of a string
Installation
$ npm install --save linecol2index
Usage
const {linecol2index} = require('linecol2index');
const text = getTextFromFile('example.py'); // "print("Hello, World!")\nprint("Goodbye!")"
const line = 2
const col = 1
const index = linecol2index(line, col, text);
console.log(text[index]) // 'p'
License
ISC © Anthony Yang