3.1.1 • Published 4 months ago

line-column-mini v3.1.1

Weekly downloads
48
License
MIT
Repository
github
Last release
4 months ago

Install

This package is pure ESM. If you're not ready yet, install an older version of this program, 1.2.0 (npm i line-column-mini@1.2.0).

npm i line-column-mini

Quick 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.

Contributing

To report bugs or request features or assistance, raise an issue on GitHub.

Licence

MIT License.

Copyright © 2010-2024 Roy Revelt and other contributors.

3.1.1

4 months ago

3.1.0

8 months ago

3.0.8

10 months ago

3.0.7

1 year ago

3.0.4

1 year ago

3.0.6

1 year ago

3.0.5

1 year ago

2.1.2

2 years ago

2.1.4

2 years ago

2.1.3

2 years ago

2.1.6

2 years ago

2.1.5

2 years ago

3.0.3

1 year ago

3.0.2

1 year ago

3.0.1

1 year ago

3.0.0

1 year ago

2.1.1

2 years ago

2.0.14

2 years ago

2.1.0

2 years ago

2.0.13

2 years ago

2.0.11

2 years ago

2.0.7

2 years ago

2.0.12

2 years ago

2.0.10

2 years ago

2.0.5

2 years ago

2.0.6

2 years ago

2.0.3

3 years ago

2.0.4

3 years ago

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.2.0

3 years ago

1.1.16

3 years ago

1.1.15

3 years ago

1.1.14

3 years ago

1.1.13

3 years ago

1.1.12

3 years ago

1.1.11

3 years ago

1.1.10

3 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.1

3 years ago

1.1.2

3 years ago

1.1.0

3 years ago