(source: string, pos: number | Pos)
| 458 | } |
| 459 | |
| 460 | export function posToNumber(source: string, pos: number | Pos): number { |
| 461 | if (typeof pos === 'number') return pos |
| 462 | const lines = source.split(splitRE) |
| 463 | const { line, column } = pos |
| 464 | let start = 0 |
| 465 | for (let i = 0; i < line - 1 && i < lines.length; i++) { |
| 466 | start += lines[i].length + 1 |
| 467 | } |
| 468 | return start + column |
| 469 | } |
| 470 | |
| 471 | export function numberToPos(source: string, offset: number | Pos): Pos { |
| 472 | if (typeof offset !== 'number') return offset |
no outgoing calls
no test coverage detected