(body: string, at: number)
| 1784 | |
| 1785 | /** Where a declarator's initializer starts, past its `: Type` and `=`; -1 when it has none. */ |
| 1786 | export function initializerAt(body: string, at: number): number { |
| 1787 | for (let i = at; i < body.length; i++) { |
| 1788 | const ch = body[i]!; |
| 1789 | if (ch === '"' || ch === "'" || ch === '`') { |
| 1790 | i = skipString(body, i); |
| 1791 | if (i < 0) return -1; |
| 1792 | } else if (ch === '{' || ch === '(' || ch === '[') { |
| 1793 | i = matchBracket(body, i); |
| 1794 | if (i < 0) return -1; |
| 1795 | } else if (ch === '=') { |
| 1796 | if (body[i + 1] === '>' || body[i + 1] === '=') i++; |
| 1797 | else return i + 1; |
| 1798 | } else if (ch === ';' || ch === ',' || ch === '}' || ch === ')') return -1; |
| 1799 | } |
| 1800 | return -1; |
| 1801 | } |
| 1802 | |
| 1803 | /** |
| 1804 | * Where the statement or declarator from `from` ends: at a `;`, a closing |
no test coverage detected