main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
733 bytes
|
Rev | Line | |
---|
[d24f17c] | 1 | /**
|
---|
| 2 | * Tracks newlines during parsing in order to provide an efficient API for
|
---|
| 3 | * determining the one-indexed `{ line, col }` position for any offset
|
---|
| 4 | * within the input.
|
---|
| 5 | */
|
---|
| 6 | export declare class LineCounter {
|
---|
| 7 | lineStarts: number[];
|
---|
| 8 | /**
|
---|
| 9 | * Should be called in ascending order. Otherwise, call
|
---|
| 10 | * `lineCounter.lineStarts.sort()` before calling `linePos()`.
|
---|
| 11 | */
|
---|
| 12 | addNewLine: (offset: number) => number;
|
---|
| 13 | /**
|
---|
| 14 | * Performs a binary search and returns the 1-indexed { line, col }
|
---|
| 15 | * position of `offset`. If `line === 0`, `addNewLine` has never been
|
---|
| 16 | * called or `offset` is before the first known newline.
|
---|
| 17 | */
|
---|
| 18 | linePos: (offset: number) => {
|
---|
| 19 | line: number;
|
---|
| 20 | col: number;
|
---|
| 21 | };
|
---|
| 22 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.