MCPcopy Index your code
hub / github.com/codeceptjs/CodeceptJS / yamlItemToNode

Function yamlItemToNode

lib/aria.js:79–101  ·  view source on GitHub ↗
(item)

Source from the content-addressed store, hash-verified

77}
78
79function yamlItemToNode(item) {
80 if (typeof item === 'string') {
81 const label = parseLabel(item)
82 if (!label) return null
83 const node = { role: label.role, name: label.name, attributes: label.attributes, children: [] }
84 return node
85 }
86 if (!item || typeof item !== 'object' || Array.isArray(item)) return null
87
88 const entries = Object.entries(item)
89 if (entries.length === 0) return null
90 const [key, value] = entries[0]
91 const label = parseLabel(key)
92 if (!label) return null
93 const node = { role: label.role, name: label.name, attributes: label.attributes, children: [] }
94
95 if (Array.isArray(value)) {
96 node.children = value.map(yamlItemToNode).filter(n => n !== null)
97 return node
98 }
99 if (value !== null && value !== undefined) node.value = String(value)
100 return node
101}
102
103function parseSnapshot(snapshot) {
104 if (!snapshot) return []

Callers

nothing calls this directly

Calls 3

parseLabelFunction · 0.85
entriesMethod · 0.80
filterMethod · 0.80

Tested by

no test coverage detected