MCPcopy Index your code
hub / github.com/simstudioai/sim / pluckByPath

Function pluckByPath

apps/sim/lib/table/pluck.ts:13–26  ·  view source on GitHub ↗
(source: unknown, path: string)

Source from the content-addressed store, hash-verified

11 * Returns undefined for any missing segment.
12 */
13export function pluckByPath(source: unknown, path: string): unknown {
14 if (source === null || source === undefined || !path) return source
15 const segments = path
16 .replace(/\[(\w+)\]/g, '.$1')
17 .split('.')
18 .filter(Boolean)
19 let cursor: unknown = source
20 for (const seg of segments) {
21 if (cursor === null || cursor === undefined) return undefined
22 if (typeof cursor !== 'object') return undefined
23 cursor = (cursor as Record<string, unknown>)[seg]
24 }
25 return cursor
26}

Callers 3

processBackfillPageFunction · 0.90
onBlockCompleteFunction · 0.85
cellOnBlockCompleteFunction · 0.85

Calls 1

replaceMethod · 0.65

Tested by

no test coverage detected