框架源码
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.

30 lines
969 B

4 years ago
  1. 'use strict';
  2. exports.__esModule = true;
  3. exports.default = function (options, extend) {
  4. Object.keys(extend).forEach(function (attr) {
  5. var value = extend[attr];
  6. if (~attr.indexOf('.')) {
  7. // eg: a.b.c a.1.b
  8. (0, _utilsLite.set)(options, attr, value);
  9. } else if (typeof value === 'function') {
  10. // get callback value
  11. options[attr] = value(options[attr]);
  12. } else {
  13. // mixin extend value
  14. if ((0, _utilsLite.isArray)(options[attr]) && (0, _utilsLite.isObject)(options[attr][0])) {
  15. // eg: [{ xx: 1 }, { xx: 2 }]
  16. options[attr].forEach(function (option, index) {
  17. options[attr][index] = Object.assign({}, option, value);
  18. });
  19. } else if ((0, _utilsLite.isObject)(options[attr])) {
  20. // eg: { xx: 1, yy: 2 }
  21. options[attr] = Object.assign({}, options[attr], value);
  22. } else {
  23. options[attr] = value;
  24. }
  25. }
  26. });
  27. };
  28. var _utilsLite = require('utils-lite');