You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
969 B
31 lines
969 B
'use strict';
|
|
|
|
exports.__esModule = true;
|
|
|
|
exports.default = function (options, extend) {
|
|
Object.keys(extend).forEach(function (attr) {
|
|
var value = extend[attr];
|
|
if (~attr.indexOf('.')) {
|
|
// eg: a.b.c a.1.b
|
|
(0, _utilsLite.set)(options, attr, value);
|
|
} else if (typeof value === 'function') {
|
|
// get callback value
|
|
options[attr] = value(options[attr]);
|
|
} else {
|
|
// mixin extend value
|
|
if ((0, _utilsLite.isArray)(options[attr]) && (0, _utilsLite.isObject)(options[attr][0])) {
|
|
// eg: [{ xx: 1 }, { xx: 2 }]
|
|
options[attr].forEach(function (option, index) {
|
|
options[attr][index] = Object.assign({}, option, value);
|
|
});
|
|
} else if ((0, _utilsLite.isObject)(options[attr])) {
|
|
// eg: { xx: 1, yy: 2 }
|
|
options[attr] = Object.assign({}, options[attr], value);
|
|
} else {
|
|
options[attr] = value;
|
|
}
|
|
}
|
|
});
|
|
};
|
|
|
|
var _utilsLite = require('utils-lite');
|