Last change
on this file since ceaed42 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
552 bytes
|
Line | |
---|
1 | # lines-and-columns
|
---|
2 |
|
---|
3 | Maps lines and columns to character offsets and back. This is useful for parsers
|
---|
4 | and other text processors that deal in character ranges but process text with
|
---|
5 | meaningful lines and columns.
|
---|
6 |
|
---|
7 | ## Install
|
---|
8 |
|
---|
9 | ```
|
---|
10 | $ npm install [--save] lines-and-columns
|
---|
11 | ```
|
---|
12 |
|
---|
13 | ## Usage
|
---|
14 |
|
---|
15 | ```js
|
---|
16 | import LinesAndColumns from 'lines-and-columns';
|
---|
17 |
|
---|
18 | const lines = new LinesAndColumns(
|
---|
19 | `table {
|
---|
20 | border: 0
|
---|
21 | }`);
|
---|
22 |
|
---|
23 | lines.locationForIndex(9); // { line: 1, column: 1 }
|
---|
24 | lines.indexForLocation({ line: 1, column: 2 }); // 10
|
---|
25 | ```
|
---|
26 |
|
---|
27 | ## License
|
---|
28 |
|
---|
29 | MIT
|
---|
Note:
See
TracBrowser
for help on using the repository browser.