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