(fn: () => unknown)
| 2 | import {createComputed, createRoot, getOwner, runWithOwner} from 'solid-js' |
| 3 | |
| 4 | export function getFunctionSources(fn: () => unknown): Solid.Signal[] { |
| 5 | let nodes: Solid.Signal[] | undefined |
| 6 | let init = true |
| 7 | runWithOwner(null as any, () => |
| 8 | createRoot(dispose => |
| 9 | createComputed(() => { |
| 10 | if (!init) return |
| 11 | init = false |
| 12 | fn() |
| 13 | const sources = (getOwner() as Solid.Computation).sources |
| 14 | if (sources) nodes = [...sources] |
| 15 | dispose() |
| 16 | }), |
| 17 | ), |
| 18 | ) |
| 19 | return nodes ?? [] |
| 20 | } |
| 21 | |
| 22 | /** |
| 23 | * For measuring the time elapsed. Returns a function that will return the time elapsed since it's last call. |
no test coverage detected
searching dependent graphs…