* The tables a value written at `at` gives: the literal there, or the * function a call there names — `getRouteMap({ … })`, `await loadRoutes()` — * whose returned table it is, and through `useMemo` what its callback * returns: `useMemo(() => getRoutes(user), [user])`, `useMemo(getRoutes, [])`.
(safe: string, at: number)
| 2168 | * returns: `useMemo(() => getRoutes(user), [user])`, `useMemo(getRoutes, [])`. |
| 2169 | */ |
| 2170 | function heldTable(safe: string, at: number): TableSite[] { |
| 2171 | // Parentheses around the value change nothing: `return ([ … ])`. |
| 2172 | while (safe[at] === '(') at = skipSpace(safe, at + 1); |
| 2173 | if (safe[at] === '[' || safe[at] === '{') return [at]; |
| 2174 | const memo = /(?:React\s*\.\s*)?useMemo\s*(?:<[^()]*>)?\s*\(\s*/y; |
| 2175 | memo.lastIndex = at; |
| 2176 | if (memo.test(safe)) { |
| 2177 | const handed = /([A-Za-z_$][\w$]*)\s*,/y; |
| 2178 | handed.lastIndex = memo.lastIndex; |
| 2179 | const fn = handed.exec(safe); |
| 2180 | return fn ? [{ name: fn[1]!, call: true, at: memo.lastIndex }] : returnedTables(safe, memo.lastIndex); |
| 2181 | } |
| 2182 | const call = /(await\s+)?([A-Za-z_$][\w$]*)\s*\(/y; |
| 2183 | call.lastIndex = at; |
| 2184 | const m = call.exec(safe); |
| 2185 | return m ? [{ name: m[2]!, call: true, at: at + (m[1]?.length ?? 0) }] : []; |
| 2186 | } |
| 2187 | |
| 2188 | /** |
| 2189 | * Picks, of a name's declarations in `file` (where each keyword sits), the |
no test coverage detected