( ancestor: JSONHeroPath, descendant: JSONHeroPath )
| 93 | } |
| 94 | |
| 95 | export function firstChildToDescendant( |
| 96 | ancestor: JSONHeroPath, |
| 97 | descendant: JSONHeroPath |
| 98 | ): string | undefined { |
| 99 | const ancestorPathComponents = ancestor.components.map((component) => |
| 100 | component.toString() |
| 101 | ); |
| 102 | const descendantPathComponents = descendant.components.map((component) => |
| 103 | component.toString() |
| 104 | ); |
| 105 | |
| 106 | const pathComponents = []; |
| 107 | |
| 108 | for (let index = 0; index < descendantPathComponents.length; index++) { |
| 109 | const descendantPathComponent = descendantPathComponents[index]; |
| 110 | |
| 111 | if (ancestorPathComponents.length >= index) { |
| 112 | pathComponents.push(descendantPathComponent); |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | return pathComponents.join("."); |
| 117 | } |
| 118 | |
| 119 | export function pathToDescendant( |
| 120 | ancestor: string, |
no outgoing calls
no test coverage detected