| 122 | } |
| 123 | |
| 124 | const normalizePath = path => { |
| 125 | const pathSegments = path.split('.') |
| 126 | const section = pathSegments.shift() |
| 127 | const name = pathSegments.pop() |
| 128 | const subsection = pathSegments.length ? pathSegments.join('.') : undefined |
| 129 | |
| 130 | return { |
| 131 | section, |
| 132 | subsection, |
| 133 | name, |
| 134 | path: getPath(section, subsection, name), |
| 135 | sectionPath: getPath(section, subsection, null), |
| 136 | isSection: !!section, |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | const findLastIndex = (array, callback) => { |
| 141 | return array.reduce((lastIndex, item, index) => { |