File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed
Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change 1- import { cloneDeep } from "lodash" ;
2-
31import NetJSONGraphDefaultConfig from "./netjsongraph.config" ;
42import 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 ] ;
Original file line number Diff line number Diff 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 *
You can’t perform that action at this time.
0 commit comments