Package Exports
- line-column-mini
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (line-column-mini) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
line-column-mini
Convert string index to line-column position
Install
npm i line-column-miniQuick Take
import { strict as assert } from "assert";
import { lineCol, getLineStartIndexes } from "line-column-mini";
// index 14 is letter "k" on the fourth line:
assert.deepEqual(lineCol("abc\ndef\r\nghi\njkl", 14), {
line: 4,
col: 2,
});
// ---------------------------------------------------------
// if you know you might query multiple times, use caching
const lineIndexes = getLineStartIndexes("abc\ndef\r\nghi\njkl");
assert.deepEqual(lineCol(lineIndexes, 14), {
line: 4,
col: 2,
});
// other queries will be by magnitude faster:
assert.deepEqual(lineCol(lineIndexes, 15), {
line: 4,
col: 3,
});
// by the way...
assert.deepEqual(lineCol(lineIndexes, 99), null);Documentation
Please visit codsen.com for a full description of the API and examples.
Contributing
To report bugs or request features or assistance, raise an issue on GitHub.
Licence
MIT License
Copyright (c) 2010-2021 Roy Revelt and other contributors
![]()