@@ -18,44 +18,43 @@ export const background = '#242529';
18
18
//
19
19
20
20
const clusterData = { } ;
21
+ let memoizeObj = { } ;
21
22
22
23
function clusterDataPopulate ( props ) {
23
- console . log ( props )
24
24
let atomCompObj = reorganizedObj ( props ) ;
25
-
26
- console . log ( atomCompObj ) ;
25
+ console . log ( atomCompObj )
27
26
28
27
if ( props [ 0 ] . name ) {
29
28
clusterData . name = props [ 0 ] . name ;
30
29
}
31
-
32
30
33
- let memoizeObj = { }
34
- let counter = 0
31
+ let counter = 0 ;
35
32
36
- for ( let key in atomCompObj ) {
37
- if ( atomCompObj [ key ] . length ) {
38
- for ( let i = 0 ; i < atomCompObj [ key ] . length ; i ++ ) {
39
-
33
+ for ( let key in atomCompObj ) {
40
34
35
+ if ( atomCompObj [ key ] . length ) {
36
+
37
+ for ( let i = 0 ; i < atomCompObj [ key ] . length ; i ++ ) {
41
38
39
+ if ( ! memoizeObj [ key ] ) {
40
+ memoizeObj [ key ] = [ ] ;
41
+ if ( ! clusterData . children ) clusterData . children = [ ] ;
42
+ clusterData . children . push ( { name : key } ) ;
43
+ }
42
44
45
+ if ( ! memoizeObj [ key ] . includes ( atomCompObj [ key ] [ i ] ) ) {
46
+
47
+ if ( ! clusterData . children [ counter ] . children ) clusterData . children [ counter ] . children = [ ]
48
+ clusterData . children [ counter ] . children . push ( { name : atomCompObj [ key ] [ i ] } ) ;
49
+ }
50
+ memoizeObj [ key ] . push ( atomCompObj [ key ] [ i ] ) ;
51
+ }
52
+ }
53
+ counter ++ ;
54
+ }
55
+ console . log ( clusterData )
56
+ }
43
57
44
- if ( ! clusterData . children ) clusterData . children = [ ]
45
- clusterData . children . push ( { name : key } ) }
46
- if ( ! clusterData . children [ counter ] . children ) {
47
- clusterData . children [ counter ] . children = [ ]
48
- clusterData . children [ counter ] . children . push ( { name :atomCompObj [ key ] [ i ] } ) }
49
-
50
- if ( ! memoizeObj [ key ] ) {
51
- memoizeObj [ key ] = [ ]
52
- memoizeObj [ key ] . push [ atomCompObj [ key ] [ i ] ]
53
- }
54
- }
55
- counter ++
56
- }
57
- console . log ( clusterData )
58
- }
59
58
60
59
function reorganizedObj ( props ) {
61
60
let atomsComponentObj = props [ 0 ] . atomsComponents ;
@@ -71,8 +70,7 @@ function reorganizedObj(props) {
71
70
}
72
71
}
73
72
return reorganizedObj ;
74
- }
75
-
73
+ }
76
74
77
75
78
76
function Node ( { node } ) {
0 commit comments