Top-level `key: Identifier` entries of an object-literal body. DEPTH-AWARE: only depth-0 * segments are considered, so method-shorthand bodies (`number(a,b){…}`), arrow values * (`x: () => …`), and nested objects (`x: { … }`) don't leak their inner `k: v` pairs as * bogus handlers. The per-seg
(body: string)
| 1762 | * bogus handlers. The per-segment anchor (`^… key: Ident …$`) keeps only pure identifier |
| 1763 | * values — a data value (`x: 5`), call, or arrow fails to match. */ |
| 1764 | function registryEntryNames(body: string): string[] { |
| 1765 | const segs: string[] = []; |
| 1766 | let depth = 0; |
| 1767 | let start = 0; |
| 1768 | for (let i = 0; i < body.length; i++) { |
| 1769 | const c = body[i]; |
| 1770 | if (c === '{' || c === '(' || c === '[') depth++; |
| 1771 | else if (c === '}' || c === ')' || c === ']') depth--; |
| 1772 | else if (c === ',' && depth === 0) { segs.push(body.slice(start, i)); start = i + 1; } |
| 1773 | } |
| 1774 | segs.push(body.slice(start)); |
| 1775 | const names: string[] = []; |
| 1776 | for (const seg of segs) { |
| 1777 | const m = /^\s*(?:\[[^\]]+\]|['"]?[\w$]+['"]?)\s*:\s*([A-Za-z_$][\w$]*)\s*$/.exec(seg); |
| 1778 | if (m && m[1]!.length >= 3 && !names.includes(m[1]!)) names.push(m[1]!); |
| 1779 | } |
| 1780 | return names; |
| 1781 | } |
| 1782 | |
| 1783 | /** Resolve a registered handler name to its callable entry: a function value, or a class's |
| 1784 | * `execute`-like method (preferring the method chained at the dispatch site), else the class. */ |
no test coverage detected