forked from lix-project/lix-website
28 lines
635 B
JavaScript
28 lines
635 B
JavaScript
|
module.exports = configure
|
||
|
|
||
|
function configure(base, extension) {
|
||
|
var index = -1
|
||
|
var key
|
||
|
|
||
|
// First do subextensions.
|
||
|
if (extension.extensions) {
|
||
|
while (++index < extension.extensions.length) {
|
||
|
configure(base, extension.extensions[index])
|
||
|
}
|
||
|
}
|
||
|
|
||
|
for (key in extension) {
|
||
|
if (key === 'extensions') {
|
||
|
// Empty.
|
||
|
} else if (key === 'unsafe' || key === 'join') {
|
||
|
base[key] = base[key].concat(extension[key] || [])
|
||
|
} else if (key === 'handlers') {
|
||
|
base[key] = Object.assign(base[key], extension[key] || {})
|
||
|
} else {
|
||
|
base.options[key] = extension[key]
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return base
|
||
|
}
|