* Where the statement or declarator from `from` ends: at a `;`, a closing * bracket, a `,` when `comma`, or at a line break neither line continues * across, where JavaScript ends a statement without a semicolon.
(text: string, from: number, comma = false)
| 1784 | * across, where JavaScript ends a statement without a semicolon. |
| 1785 | */ |
| 1786 | function statementEnd(text: string, from: number, comma = false): number { |
| 1787 | let last = ''; |
| 1788 | for (let i = from; i < text.length; i++) { |
| 1789 | const ch = text[i]!; |
| 1790 | if (ch === '"' || ch === "'" || ch === '`' || ch === '{' || ch === '(' || ch === '[') { |
| 1791 | const end = ch === '{' || ch === '(' || ch === '[' ? matchBracket(text, i) : skipString(text, i); |
| 1792 | if (end < 0) return text.length; |
| 1793 | i = end; |
| 1794 | last = text[end]!; |
| 1795 | continue; |
| 1796 | } |
| 1797 | if (ch === ';' || ch === '}' || ch === ')' || ch === ']' || (comma && ch === ',')) return i; |
| 1798 | if (ch === '\n') { |
| 1799 | let j = i + 1; |
| 1800 | while (j < text.length && /\s/.test(text[j]!)) j++; |
| 1801 | if (last && !/[=(,[{?:&|+\-*/%<>!.]/.test(last) && !/[.?:&|+\-*/%=<>,([]/.test(text[j] ?? '')) return i; |
| 1802 | continue; |
| 1803 | } |
| 1804 | if (!/\s/.test(ch)) last = ch; |
| 1805 | } |
| 1806 | return text.length; |
| 1807 | } |
| 1808 | |
| 1809 | /** What expression `text` evaluates to in a loader, or null when it is not one this reads. */ |
| 1810 | function valueOf(text: string, scope: LoaderScope): Loaded | null { |
no test coverage detected