line-and-column-to-string-index
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

line-and-column-to-string-index

TypeScript function which converts 0-based line and column into an index into a string

Usage

import { lineColumnToIndex } from "line-and-column-to-string-index";

const myString = `
something something blah blah
blah fjdkfdsjfklds
dsjfkdsljfkldsjfklsdsjfkdsjfl!!
`;

const line = 2; // 0-based
const column = 2; // 0-based

const index = lineColumnToIndex(myString, line, column);
console.log(index); // 33

License

MIT

Dependencies (0)

    Dev Dependencies (2)

    Package Sidebar

    Install

    npm i line-and-column-to-string-index

    Weekly Downloads

    1

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    3.51 kB

    Total Files

    8

    Last publish

    Collaborators

    • suchipi