* 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)
| 2190 | * returns: `useMemo(() => getRoutes(user), [user])`, `useMemo(getRoutes, [])`. |
| 2191 | */ |
| 2192 | function heldTable(safe: string, at: number): TableSite[] { |
| 2193 | // Parentheses around the value change nothing: `return ([ … ])`. |
| 2194 | while (safe[at] === '(') at = skipSpace(safe, at + 1); |
| 2195 | if (safe[at] === '[' || safe[at] === '{') return [at]; |
| 2196 | const memo = /(?:React\s*\.\s*)?useMemo\s*(?:<[^()]*>)?\s*\(\s*/y; |
| 2197 | memo.lastIndex = at; |
| 2198 | if (memo.test(safe)) { |
| 2199 | const handed = /([A-Za-z_$][\w$]*)\s*,/y; |
| 2200 | handed.lastIndex = memo.lastIndex; |
| 2201 | const fn = handed.exec(safe); |
| 2202 | return fn ? [{ name: fn[1]!, call: true, at: memo.lastIndex }] : returnedTables(safe, memo.lastIndex); |
| 2203 | } |
| 2204 | const call = /(await\s+)?([A-Za-z_$][\w$]*)\s*\(/y; |
| 2205 | call.lastIndex = at; |
| 2206 | const m = call.exec(safe); |
| 2207 | return m ? [{ name: m[2]!, call: true, at: at + (m[1]?.length ?? 0) }] : []; |
| 2208 | } |
| 2209 | |
| 2210 | /** |
| 2211 | * Picks, of a name's declarations in `file` (where each keyword sits), the |
no test coverage detected