1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | function merge(target) {
|
9 | var args = [];
|
10 | for (var _i = 1; _i < arguments.length; _i++) {
|
11 | args[_i - 1] = arguments[_i];
|
12 | }
|
13 | for (var _a = 0, args_1 = args; _a < args_1.length; _a++) {
|
14 | var arg = args_1[_a];
|
15 | _merge(target || {}, arg);
|
16 | }
|
17 | return target;
|
18 | }
|
19 | exports.merge = merge;
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 | function _merge(target, source, circularReferences) {
|
28 | if (circularReferences === void 0) { circularReferences = []; }
|
29 | circularReferences.push(source);
|
30 | for (var name_1 in source) {
|
31 | if (source.hasOwnProperty(name_1)) {
|
32 | if (name_1 !== '__proto__' && name_1 !== 'constructor' && name_1 !== 'prototype') {
|
33 | var value = source[name_1];
|
34 | if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
|
35 | var isCircularReference = circularReferences.indexOf(value) > -1;
|
36 | target[name_1] = (isCircularReference
|
37 | ? value
|
38 | : _merge(target[name_1] || {}, value, circularReferences));
|
39 | }
|
40 | else {
|
41 | target[name_1] = value;
|
42 | }
|
43 | }
|
44 | }
|
45 | }
|
46 | circularReferences.pop();
|
47 | return target;
|
48 | }
|
49 |
|
\ | No newline at end of file |