1 | "use strict";
|
2 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
3 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
4 | };
|
5 | Object.defineProperty(exports, "__esModule", { value: true });
|
6 | var is_array_1 = __importDefault(require("@antv/util/lib/is-array"));
|
7 | var for_in_1 = __importDefault(require("@antv/util/lib/for-in"));
|
8 | var cloneDeep = function (deepObject) {
|
9 | var map = [];
|
10 | var clone = function (obj) {
|
11 | map.push(obj);
|
12 | if (map.includes(obj)) {
|
13 | return obj;
|
14 | }
|
15 | if (typeof obj !== 'object' || obj === null) {
|
16 | return obj;
|
17 | }
|
18 | var rst;
|
19 | if (is_array_1.default(obj)) {
|
20 | rst = [];
|
21 | for (var i = 0, l = obj.length; i < l; i++) {
|
22 | if (typeof obj[i] === 'object' && obj[i] != null) {
|
23 | rst[i] = clone(obj[i]);
|
24 | }
|
25 | else {
|
26 | rst[i] = obj[i];
|
27 | }
|
28 | }
|
29 | }
|
30 | else {
|
31 | rst = {};
|
32 | for_in_1.default(obj, function (value, k) {
|
33 | if (typeof value === 'object' && value != null) {
|
34 | rst[k] = clone(value);
|
35 | }
|
36 | else {
|
37 | rst[k] = value;
|
38 | }
|
39 | });
|
40 | }
|
41 | return rst;
|
42 | };
|
43 | return clone(deepObject);
|
44 | };
|
45 | exports.default = cloneDeep;
|
46 |
|
\ | No newline at end of file |