vigour-config
Version:
Observable configuration
36 lines (32 loc) • 764 B
JavaScript
exports.define = {
resolve: resolve
}
function resolve (path, options) {
var config = this
var skipVal = options && options.skipVal
var found = config.find(path)
var deep = path instanceof Array && path.length
// var deep = true
for (let i = 0, target; (target = found[i]); i++) { // eslint-disable-line
var setTarget = target.parent
if (deep) {
var up = deep - 1
while (up--) {
setTarget = setTarget.parent
}
}
var setobj = target.serialize()
if (skipVal) {
delete setobj.val
}
setTarget.set(setobj)
}
// the best way to do this is what parse val and using val
if (!deep && path[0] === '#') {
config.set({
branch: path.slice(1)
})
}
return config
}