MCPcopy Create free account
hub / github.com/chakra-ui/panda / getDotPath

Function getDotPath

packages/shared/src/split.ts:38–56  ·  view source on GitHub ↗
(obj: any, path: string, fallback?: any)

Source from the content-addressed store, hash-verified

36}
37
38export function getDotPath(obj: any, path: string, fallback?: any): any {
39 if (typeof path !== 'string') return fallback
40
41 const idx = path.indexOf('.')
42
43 if (idx === -1) {
44 return obj?.[path] ?? fallback
45 }
46
47 const key = path.slice(0, idx)
48 const nextPath = path.slice(idx + 1)
49
50 const checkValue = obj?.[key]?.[nextPath]
51 if (checkValue) {
52 return checkValue
53 }
54
55 return getDotPath(obj?.[key], nextPath, fallback) ?? fallback
56}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected