Skip to content

Commit 5e77956

Browse files
committed
[fix] Custom deepCopy function instead of loadlash
1 parent 8da8bc1 commit 5e77956

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/js/netjsongraph.core.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import {cloneDeep} from "lodash";
2-
31
import NetJSONGraphDefaultConfig from "./netjsongraph.config";
42
import NetJSONGraphUpdate from "./netjsongraph.update";
53

@@ -12,7 +10,7 @@ class NetJSONGraph {
1210
*/
1311
constructor(JSONParam) {
1412
this.utils = new NetJSONGraphUpdate();
15-
this.config = cloneDeep(NetJSONGraphDefaultConfig);
13+
this.config = this.utils.deepCopy(NetJSONGraphDefaultConfig);
1614
// deepMergeObj is overriding the crs from the NetJSONGraphDefaultConfig after deep copy.
1715
this.config.crs = NetJSONGraphDefaultConfig.crs;
1816
this.JSONParam = this.utils.isArray(JSONParam) ? JSONParam : [JSONParam];

src/js/netjsongraph.util.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,21 @@ class NetJSONGraphUtil {
260260
return convertGeojson(geojson);
261261
}
262262

263+
deepCopy(obj) {
264+
if (obj === null || typeof obj !== "object") {
265+
return obj;
266+
}
267+
if (Array.isArray(obj)) {
268+
return obj.map(item => this.deepCopy(item));
269+
}
270+
const result = {};
271+
const keys = Object.keys(obj);
272+
for (const key of keys) {
273+
result[key] = this.deepCopy(obj[key]);
274+
}
275+
return result;
276+
}
277+
263278
/**
264279
* merge two object deeply
265280
*

0 commit comments

Comments
 (0)