(source: string, timeoutMs?: number)
| 610 | } |
| 611 | |
| 612 | function parseSource(source: string, timeoutMs?: number): TsNode | null { |
| 613 | const L = makeLexer(source) |
| 614 | const srcBytes = byteLengthUtf8(source) |
| 615 | const P: ParseState = { |
| 616 | L, |
| 617 | src: source, |
| 618 | srcBytes, |
| 619 | isAscii: srcBytes === source.length, |
| 620 | nodeCount: 0, |
| 621 | deadline: performance.now() + (timeoutMs ?? PARSE_TIMEOUT_MS), |
| 622 | aborted: false, |
| 623 | inBacktick: 0, |
| 624 | stopToken: null, |
| 625 | } |
| 626 | try { |
| 627 | const program = parseProgram(P) |
| 628 | if (P.aborted) return null |
| 629 | return program |
| 630 | } catch { |
| 631 | return null |
| 632 | } |
| 633 | } |
| 634 | |
| 635 | function byteLengthUtf8(s: string): number { |
| 636 | let b = 0 |
nothing calls this directly
no test coverage detected