* 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)
| 1806 | * across, where JavaScript ends a statement without a semicolon. |
| 1807 | */ |
| 1808 | function statementEnd(text: string, from: number, comma = false): number { |
| 1809 | let last = ''; |
| 1810 | for (let i = from; i < text.length; i++) { |
| 1811 | const ch = text[i]!; |
| 1812 | if (ch === '"' || ch === "'" || ch === '`' || ch === '{' || ch === '(' || ch === '[') { |
| 1813 | const end = ch === '{' || ch === '(' || ch === '[' ? matchBracket(text, i) : skipString(text, i); |
| 1814 | if (end < 0) return text.length; |
| 1815 | i = end; |
| 1816 | last = text[end]!; |
| 1817 | continue; |
| 1818 | } |
| 1819 | if (ch === ';' || ch === '}' || ch === ')' || ch === ']' || (comma && ch === ',')) return i; |
| 1820 | if (ch === '\n') { |
| 1821 | let j = i + 1; |
| 1822 | while (j < text.length && /\s/.test(text[j]!)) j++; |
| 1823 | if (last && !/[=(,[{?:&|+\-*/%<>!.]/.test(last) && !/[.?:&|+\-*/%=<>,([]/.test(text[j] ?? '')) return i; |
| 1824 | continue; |
| 1825 | } |
| 1826 | if (!/\s/.test(ch)) last = ch; |
| 1827 | } |
| 1828 | return text.length; |
| 1829 | } |
| 1830 | |
| 1831 | /** What expression `text` evaluates to in a loader, or null when it is not one this reads. */ |
| 1832 | function valueOf(text: string, scope: LoaderScope): Loaded | null { |
no test coverage detected