(source: string, offset: number | Pos)
| 469 | } |
| 470 | |
| 471 | export function numberToPos(source: string, offset: number | Pos): Pos { |
| 472 | if (typeof offset !== 'number') return offset |
| 473 | if (offset > source.length) { |
| 474 | throw new Error( |
| 475 | `offset is longer than source length! offset ${offset} > length ${source.length}`, |
| 476 | ) |
| 477 | } |
| 478 | |
| 479 | const lines = source.slice(0, offset).split(splitRE) |
| 480 | return { |
| 481 | line: lines.length, |
| 482 | column: lines[lines.length - 1].length, |
| 483 | } |
| 484 | } |
| 485 | |
| 486 | const MAX_DISPLAY_LEN = 120 |
| 487 | const ELLIPSIS = '...' |
no outgoing calls
no test coverage detected