* Calculate the depth of a YAML/JSON object
(obj: any)
| 65 | * Calculate the depth of a YAML/JSON object |
| 66 | */ |
| 67 | function 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 | } |
no outgoing calls
no test coverage detected