Offsets of the file's line starts, for the offset of a 1-based line and a column.
(source: string)
| 29 | |
| 30 | /** Offsets of the file's line starts, for the offset of a 1-based line and a column. */ |
| 31 | function lineStartsOf(source: string): number[] { |
| 32 | const starts = [0]; |
| 33 | for (let k = source.indexOf('\n'); k >= 0; k = source.indexOf('\n', k + 1)) starts.push(k + 1); |
| 34 | return starts; |
| 35 | } |
| 36 | |
| 37 | /** The index of the last range starting at or before `offset`, or -1. */ |
| 38 | function lastStartingBefore(starts: ArrayLike<number>, offset: number): number { |