Unit refactor done

This commit is contained in:
Bán Dénes 2021-01-01 21:46:01 +01:00
parent cd90705ba1
commit 83addc0879
8 changed files with 63 additions and 62 deletions

View file

@ -48,12 +48,13 @@ const _inherit = exports._inherit = (config, root, breadcrumbs) => {
breadcrumbs.push(key)
let newval = _inherit(val, root, breadcrumbs)
if (newval && newval.extends !== undefined) {
let candidates = [newval.extends]
let candidates = u.deepcopy(newval.extends)
if (a.type(candidates)() !== 'array') candidates = [candidates]
const list = [newval]
while (candidates.length) {
const path = candidates.shift()
const other = u.deepcopy(u.deep(root, path))
a.assert(other, `"${path}" (reached from "${breadcrumbs.join('.')}.${key}.extends") does not name a valid target!`)
a.assert(other, `"${path}" (reached from "${breadcrumbs.join('.')}.extends") does not name a valid inheritance target!`)
let parents = other.extends || []
if (a.type(parents)() !== 'array') parents = [parents]
candidates = candidates.concat(parents)