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

Function getYamlDepth

apps/sim/lib/file-parsers/yaml-parser.ts:67–76  ·  view source on GitHub ↗

* Calculate the depth of a YAML/JSON object

(obj: any)

Source from the content-addressed store, hash-verified

65 * Calculate the depth of a YAML/JSON object
66 */
67function getYamlDepth(obj: any): number {
68 if (obj === null || typeof obj !== 'object') return 0
69
70 if (Array.isArray(obj)) {
71 return obj.length > 0 ? 1 + Math.max(...obj.map(getYamlDepth)) : 1
72 }
73
74 const depths = Object.values(obj).map(getYamlDepth)
75 return depths.length > 0 ? 1 + Math.max(...depths) : 1
76}

Callers 2

parseYAMLFunction · 0.85
parseYAMLBufferFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected