mergeDeep.js 887 B

1234567891011121314151617181920212223242526
  1. Object.defineProperty(exports, "__esModule", { value: true });
  2. function mergeDeep(target, source) {
  3. var output = Object.assign({}, target);
  4. if (isObject(target) && isObject(source)) {
  5. Object.keys(source).forEach(function (key) {
  6. var _a, _b;
  7. if (isObject(source[key])) {
  8. if (!(key in target)) {
  9. Object.assign(output, (_a = {}, _a[key] = source[key], _a));
  10. }
  11. else {
  12. output[key] = mergeDeep(target[key], source[key]);
  13. }
  14. }
  15. else {
  16. Object.assign(output, (_b = {}, _b[key] = source[key], _b));
  17. }
  18. });
  19. }
  20. return output;
  21. }
  22. exports.default = mergeDeep;
  23. function isObject(item) {
  24. return item && typeof item === 'object' && !Array.isArray(item);
  25. }
  26. //# sourceMappingURL=mergeDeep.js.map