MCPcopy Create free account
hub / github.com/thetarnav/solid-devtools / getFunctionSources

Function getFunctionSources

packages/logger/src/utils.ts:4–20  ·  view source on GitHub ↗
(fn: () => unknown)

Source from the content-addressed store, hash-verified

2import {createComputed, createRoot, getOwner, runWithOwner} from 'solid-js'
3
4export 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.

Callers 3

debugSignalFunction · 0.90
debugSignalsFunction · 0.90
debugPropsFunction · 0.90

Calls 1

fnFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…