From the index of an opening `{`, return the brace-balanced body up to its matching `}`.
(src: string, openIdx: number)
| 2169 | |
| 2170 | /** From the index of an opening `{`, return the brace-balanced body up to its matching `}`. */ |
| 2171 | function braceBody(src: string, openIdx: number): string | null { |
| 2172 | let depth = 0; |
| 2173 | for (let i = openIdx; i < src.length; i++) { |
| 2174 | if (src[i] === '{') depth++; |
| 2175 | else if (src[i] === '}' && --depth === 0) return src.slice(openIdx + 1, i); |
| 2176 | } |
| 2177 | return null; |
| 2178 | } |
| 2179 | |
| 2180 | /** Top-level `key: Identifier` entries of an object-literal body. DEPTH-AWARE: only depth-0 |
| 2181 | * segments are considered, so method-shorthand bodies (`number(a,b){…}`), arrow values |
no outgoing calls
no test coverage detected