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

Function traverseObjectPathInternal

apps/sim/lib/core/utils/response-format.ts:195–230  ·  view source on GitHub ↗

* Internal helper to traverse an object path without parsing * @param obj The object to traverse * @param path The dot-separated path (e.g., "result.data.value") * @returns The value at the path, or undefined if path doesn't exist

(obj: any, path: string)

Source from the content-addressed store, hash-verified

193 * @returns The value at the path, or undefined if path doesn't exist
194 */
195function traverseObjectPathInternal(obj: any, path: string): any {
196 if (!path) return obj
197
198 let current = obj
199 const parts = path.split('.')
200
201 for (const part of parts) {
202 if (isLargeValueRef(current)) {
203 current = materializeLargeValueRefSyncOrThrow(current)
204 }
205
206 if (isLargeArrayManifest(current)) {
207 if (part === 'length' || part === 'totalCount') {
208 current = current.totalCount
209 continue
210 }
211 if (part === 'chunkCount' || part === 'byteSize' || part === 'preview') {
212 current = current[part]
213 continue
214 }
215 return undefined
216 }
217
218 if (current?.[part] !== undefined) {
219 current = current[part]
220 } else {
221 return undefined
222 }
223 }
224
225 if (isLargeValueRef(current)) {
226 return current
227 }
228
229 return current
230}
231
232/**
233 * Traverses an object path safely, returning undefined if any part doesn't exist

Callers 2

extractFieldValuesFunction · 0.85
traverseObjectPathFunction · 0.85

Calls 3

isLargeValueRefFunction · 0.90
isLargeArrayManifestFunction · 0.90

Tested by

no test coverage detected