Build a node. Slices text from source by byte range via char-index lookup.
( P: ParseState, type: string, start: number, end: number, children: TsNode[], )
| 658 | |
| 659 | /** Build a node. Slices text from source by byte range via char-index lookup. */ |
| 660 | function mk( |
| 661 | P: ParseState, |
| 662 | type: string, |
| 663 | start: number, |
| 664 | end: number, |
| 665 | children: TsNode[], |
| 666 | ): TsNode { |
| 667 | checkBudget(P) |
| 668 | return { |
| 669 | type, |
| 670 | text: sliceBytes(P, start, end), |
| 671 | startIndex: start, |
| 672 | endIndex: end, |
| 673 | children, |
| 674 | } |
| 675 | } |
| 676 | |
| 677 | function sliceBytes(P: ParseState, startByte: number, endByte: number): string { |
| 678 | if (P.isAscii) return P.src.slice(startByte, endByte) |
no test coverage detected