@@ -69,13 +69,13 @@ function dfsFAS(g) {
69
69
let visited = { } ;
70
70
71
71
function dfs ( v ) {
72
- if ( visited . hasOwnProperty ( v ) ) {
72
+ if ( Object . hasOwn ( visited , v ) ) {
73
73
return ;
74
74
}
75
75
visited [ v ] = true ;
76
76
stack [ v ] = true ;
77
77
g . outEdges ( v ) . forEach ( e => {
78
- if ( stack . hasOwnProperty ( e . w ) ) {
78
+ if ( Object . hasOwn ( stack , e . w ) ) {
79
79
fas . push ( e ) ;
80
80
} else {
81
81
dfs ( e . w ) ;
@@ -115,7 +115,7 @@ function addBorderSegments(g) {
115
115
children . forEach ( dfs ) ;
116
116
}
117
117
118
- if ( node . hasOwnProperty ( "minRank" ) ) {
118
+ if ( Object . hasOwn ( node , "minRank" ) ) {
119
119
node . borderLeft = [ ] ;
120
120
node . borderRight = [ ] ;
121
121
for ( let rank = node . minRank , maxRank = node . maxRank + 1 ;
@@ -185,7 +185,7 @@ function reverseY(g) {
185
185
g . edges ( ) . forEach ( e => {
186
186
let edge = g . edge ( e ) ;
187
187
edge . points . forEach ( reverseYOne ) ;
188
- if ( edge . hasOwnProperty ( "y" ) ) {
188
+ if ( Object . hasOwn ( edge , "y" ) ) {
189
189
reverseYOne ( edge ) ;
190
190
}
191
191
} ) ;
@@ -201,7 +201,7 @@ function swapXY(g) {
201
201
g . edges ( ) . forEach ( e => {
202
202
let edge = g . edge ( e ) ;
203
203
edge . points . forEach ( swapXYOne ) ;
204
- if ( edge . hasOwnProperty ( "x" ) ) {
204
+ if ( Object . hasOwn ( edge , "x" ) ) {
205
205
swapXYOne ( edge ) ;
206
206
}
207
207
} ) ;
@@ -519,7 +519,7 @@ function updateInputGraph(inputGraph, layoutGraph) {
519
519
let layoutLabel = layoutGraph . edge ( e ) ;
520
520
521
521
inputLabel . points = layoutLabel . points ;
522
- if ( layoutLabel . hasOwnProperty ( "x" ) ) {
522
+ if ( Object . hasOwn ( layoutLabel , "x" ) ) {
523
523
inputLabel . x = layoutLabel . x ;
524
524
inputLabel . y = layoutLabel . y ;
525
525
}
@@ -668,7 +668,7 @@ function translateGraph(g) {
668
668
g . nodes ( ) . forEach ( v => getExtremes ( g . node ( v ) ) ) ;
669
669
g . edges ( ) . forEach ( e => {
670
670
let edge = g . edge ( e ) ;
671
- if ( edge . hasOwnProperty ( "x" ) ) {
671
+ if ( Object . hasOwn ( edge , "x" ) ) {
672
672
getExtremes ( edge ) ;
673
673
}
674
674
} ) ;
@@ -688,8 +688,8 @@ function translateGraph(g) {
688
688
p . x -= minX ;
689
689
p . y -= minY ;
690
690
} ) ;
691
- if ( edge . hasOwnProperty ( "x" ) ) { edge . x -= minX ; }
692
- if ( edge . hasOwnProperty ( "y" ) ) { edge . y -= minY ; }
691
+ if ( Object . hasOwn ( edge , "x" ) ) { edge . x -= minX ; }
692
+ if ( Object . hasOwn ( edge , "y" ) ) { edge . y -= minY ; }
693
693
} ) ;
694
694
695
695
graphLabel . width = maxX - minX + marginX ;
@@ -718,7 +718,7 @@ function assignNodeIntersects(g) {
718
718
function fixupEdgeLabelCoords ( g ) {
719
719
g . edges ( ) . forEach ( e => {
720
720
let edge = g . edge ( e ) ;
721
- if ( edge . hasOwnProperty ( "x" ) ) {
721
+ if ( Object . hasOwn ( edge , "x" ) ) {
722
722
if ( edge . labelpos === "l" || edge . labelpos === "r" ) {
723
723
edge . width -= edge . labeloffset ;
724
724
}
@@ -873,7 +873,8 @@ module.exports = {
873
873
function run ( g ) {
874
874
let root = util . addDummyNode ( g , "root" , { } , "_root" ) ;
875
875
let depths = treeDepths ( g ) ;
876
- let height = Math . max ( ...Object . values ( depths ) ) - 1 ; // Note: depths is an Object not an array
876
+ let depthsArr = Object . values ( depths ) ;
877
+ let height = util . applyWithChunking ( Math . max , depthsArr ) - 1 ; // Note: depths is an Object not an array
877
878
let nodeSep = 2 * height + 1 ;
878
879
879
880
g . graph ( ) . nestingRoot = root ;
@@ -1195,7 +1196,7 @@ function buildLayerGraph(g, rank, relationship) {
1195
1196
result . setEdge ( u , v , { weight : g . edge ( e ) . weight + weight } ) ;
1196
1197
} ) ;
1197
1198
1198
- if ( node . hasOwnProperty ( "minRank" ) ) {
1199
+ if ( Object . hasOwn ( node , "minRank" ) ) {
1199
1200
result . setNode ( v , {
1200
1201
borderLeft : node . borderLeft [ rank ] ,
1201
1202
borderRight : node . borderRight [ rank ]
@@ -1385,7 +1386,8 @@ module.exports = initOrder;
1385
1386
function initOrder ( g ) {
1386
1387
let visited = { } ;
1387
1388
let simpleNodes = g . nodes ( ) . filter ( v => ! g . children ( v ) . length ) ;
1388
- let maxRank = Math . max ( ...simpleNodes . map ( v => g . node ( v ) . rank ) ) ;
1389
+ let simpleNodesRanks = simpleNodes . map ( v => g . node ( v ) . rank ) ;
1390
+ let maxRank = util . applyWithChunking ( Math . max , simpleNodesRanks ) ;
1389
1391
let layers = util . range ( maxRank + 1 ) . map ( ( ) => [ ] ) ;
1390
1392
1391
1393
function dfs ( v ) {
@@ -1545,7 +1547,7 @@ function sortSubgraph(g, v, cg, biasRight) {
1545
1547
if ( g . children ( entry . v ) . length ) {
1546
1548
let subgraphResult = sortSubgraph ( g , entry . v , cg , biasRight ) ;
1547
1549
subgraphs [ entry . v ] = subgraphResult ;
1548
- if ( subgraphResult . hasOwnProperty ( "barycenter" ) ) {
1550
+ if ( Object . hasOwn ( subgraphResult , "barycenter" ) ) {
1549
1551
mergeBarycenters ( entry , subgraphResult ) ;
1550
1552
}
1551
1553
}
@@ -1561,7 +1563,7 @@ function sortSubgraph(g, v, cg, biasRight) {
1561
1563
if ( g . predecessors ( bl ) . length ) {
1562
1564
let blPred = g . node ( g . predecessors ( bl ) [ 0 ] ) ,
1563
1565
brPred = g . node ( g . predecessors ( br ) [ 0 ] ) ;
1564
- if ( ! result . hasOwnProperty ( "barycenter" ) ) {
1566
+ if ( ! Object . hasOwn ( result , "barycenter" ) ) {
1565
1567
result . barycenter = 0 ;
1566
1568
result . weight = 0 ;
1567
1569
}
@@ -1604,7 +1606,7 @@ module.exports = sort;
1604
1606
1605
1607
function sort ( entries , biasRight ) {
1606
1608
let parts = util . partition ( entries , entry => {
1607
- return entry . hasOwnProperty ( "barycenter" ) ;
1609
+ return Object . hasOwn ( entry , "barycenter" ) ;
1608
1610
} ) ;
1609
1611
let sortable = parts . lhs ,
1610
1612
unsortable = parts . rhs . sort ( ( a , b ) => b . i - a . i ) ,
@@ -1896,7 +1898,7 @@ function hasConflict(conflicts, v, w) {
1896
1898
v = w ;
1897
1899
w = tmp ;
1898
1900
}
1899
- return ! ! conflicts [ v ] && conflicts [ v ] . hasOwnProperty ( w ) ;
1901
+ return ! ! conflicts [ v ] && Object . hasOwn ( conflicts [ v ] , w ) ;
1900
1902
}
1901
1903
1902
1904
/*
@@ -2057,8 +2059,8 @@ function findSmallestWidthAlignment(g, xss) {
2057
2059
*/
2058
2060
function alignCoordinates ( xss , alignTo ) {
2059
2061
let alignToVals = Object . values ( alignTo ) ,
2060
- alignToMin = Math . min ( ... alignToVals ) ,
2061
- alignToMax = Math . max ( ... alignToVals ) ;
2062
+ alignToMin = util . applyWithChunking ( Math . min , alignToVals ) ,
2063
+ alignToMax = util . applyWithChunking ( Math . max , alignToVals ) ;
2062
2064
2063
2065
[ "u" , "d" ] . forEach ( vert => {
2064
2066
[ "l" , "r" ] . forEach ( horiz => {
@@ -2068,9 +2070,9 @@ function alignCoordinates(xss, alignTo) {
2068
2070
if ( xs === alignTo ) return ;
2069
2071
2070
2072
let xsVals = Object . values ( xs ) ;
2071
- let delta = alignToMin - Math . min ( ... xsVals ) ;
2073
+ let delta = alignToMin - util . applyWithChunking ( Math . min , xsVals ) ;
2072
2074
if ( horiz !== "l" ) {
2073
- delta = alignToMax - Math . max ( ... xsVals ) ;
2075
+ delta = alignToMax - util . applyWithChunking ( Math . max , xsVals ) ;
2074
2076
}
2075
2077
2076
2078
if ( delta ) {
@@ -2133,7 +2135,7 @@ function sep(nodeSep, edgeSep, reverseSep) {
2133
2135
let delta ;
2134
2136
2135
2137
sum += vLabel . width / 2 ;
2136
- if ( vLabel . hasOwnProperty ( "labelpos" ) ) {
2138
+ if ( Object . hasOwn ( vLabel , "labelpos" ) ) {
2137
2139
switch ( vLabel . labelpos . toLowerCase ( ) ) {
2138
2140
case "l" : delta = - vLabel . width / 2 ; break ;
2139
2141
case "r" : delta = vLabel . width / 2 ; break ;
@@ -2148,7 +2150,7 @@ function sep(nodeSep, edgeSep, reverseSep) {
2148
2150
sum += ( wLabel . dummy ? edgeSep : nodeSep ) / 2 ;
2149
2151
2150
2152
sum += wLabel . width / 2 ;
2151
- if ( wLabel . hasOwnProperty ( "labelpos" ) ) {
2153
+ if ( Object . hasOwn ( wLabel , "labelpos" ) ) {
2152
2154
switch ( wLabel . labelpos . toLowerCase ( ) ) {
2153
2155
case "l" : delta = wLabel . width / 2 ; break ;
2154
2156
case "r" : delta = - wLabel . width / 2 ; break ;
@@ -2483,7 +2485,7 @@ function dfsAssignLowLim(tree, visited, nextLim, v, parent) {
2483
2485
2484
2486
visited [ v ] = true ;
2485
2487
tree . neighbors ( v ) . forEach ( w => {
2486
- if ( ! visited . hasOwnProperty ( w ) ) {
2488
+ if ( ! Object . hasOwn ( visited , w ) ) {
2487
2489
nextLim = dfsAssignLowLim ( tree , visited , nextLim , w , v ) ;
2488
2490
}
2489
2491
} ) ;
@@ -2588,6 +2590,8 @@ function isDescendant(tree, vLabel, rootLabel) {
2588
2590
} , { "../util" :27 , "./feasible-tree" :23 , "./util" :26 , "@dagrejs/graphlib" :29 } ] , 26 :[ function ( require , module , exports ) {
2589
2591
"use strict" ;
2590
2592
2593
+ const { applyWithChunking } = require ( "../util" ) ;
2594
+
2591
2595
module . exports = {
2592
2596
longestPath : longestPath ,
2593
2597
slack : slack
@@ -2619,18 +2623,20 @@ function longestPath(g) {
2619
2623
2620
2624
function dfs ( v ) {
2621
2625
var label = g . node ( v ) ;
2622
- if ( visited . hasOwnProperty ( v ) ) {
2626
+ if ( Object . hasOwn ( visited , v ) ) {
2623
2627
return label . rank ;
2624
2628
}
2625
2629
visited [ v ] = true ;
2626
2630
2627
- var rank = Math . min ( ... g . outEdges ( v ) . map ( e => {
2631
+ let outEdgesMinLens = g . outEdges ( v ) . map ( e => {
2628
2632
if ( e == null ) {
2629
2633
return Number . POSITIVE_INFINITY ;
2630
2634
}
2631
2635
2632
2636
return dfs ( e . w ) - g . edge ( e ) . minlen ;
2633
- } ) ) ;
2637
+ } ) ;
2638
+
2639
+ var rank = applyWithChunking ( Math . min , outEdgesMinLens ) ;
2634
2640
2635
2641
if ( rank === Number . POSITIVE_INFINITY ) {
2636
2642
rank = 0 ;
@@ -2650,7 +2656,7 @@ function slack(g, e) {
2650
2656
return g . node ( e . w ) . rank - g . node ( e . v ) . rank - g . edge ( e ) . minlen ;
2651
2657
}
2652
2658
2653
- } , { } ] , 27 :[ function ( require , module , exports ) {
2659
+ } , { "../util" : 27 } ] , 27 :[ function ( require , module , exports ) {
2654
2660
/* eslint "no-console": off */
2655
2661
2656
2662
"use strict" ;
@@ -2660,6 +2666,7 @@ let Graph = require("@dagrejs/graphlib").Graph;
2660
2666
module . exports = {
2661
2667
addBorderNode,
2662
2668
addDummyNode,
2669
+ applyWithChunking,
2663
2670
asNonCompoundGraph,
2664
2671
buildLayerMatrix,
2665
2672
intersectRect,
@@ -2806,25 +2813,27 @@ function buildLayerMatrix(g) {
2806
2813
* rank(v) >= 0 and at least one node w has rank(w) = 0.
2807
2814
*/
2808
2815
function normalizeRanks ( g ) {
2809
- let min = Math . min ( ... g . nodes ( ) . map ( v => {
2816
+ let nodeRanks = g . nodes ( ) . map ( v => {
2810
2817
let rank = g . node ( v ) . rank ;
2811
2818
if ( rank === undefined ) {
2812
2819
return Number . MAX_VALUE ;
2813
2820
}
2814
2821
2815
2822
return rank ;
2816
- } ) ) ;
2823
+ } ) ;
2824
+ let min = applyWithChunking ( Math . min , nodeRanks ) ;
2817
2825
g . nodes ( ) . forEach ( v => {
2818
2826
let node = g . node ( v ) ;
2819
- if ( node . hasOwnProperty ( "rank" ) ) {
2827
+ if ( Object . hasOwn ( node , "rank" ) ) {
2820
2828
node . rank -= min ;
2821
2829
}
2822
2830
} ) ;
2823
2831
}
2824
2832
2825
2833
function removeEmptyRanks ( g ) {
2826
2834
// Ranks may not start at 0, so we need to offset them
2827
- let offset = Math . min ( ...g . nodes ( ) . map ( v => g . node ( v ) . rank ) ) ;
2835
+ let nodeRanks = g . nodes ( ) . map ( v => g . node ( v ) . rank ) ;
2836
+ let offset = applyWithChunking ( Math . min , nodeRanks ) ;
2828
2837
2829
2838
let layers = [ ] ;
2830
2839
g . nodes ( ) . forEach ( v => {
@@ -2858,15 +2867,37 @@ function addBorderNode(g, prefix, rank, order) {
2858
2867
return addDummyNode ( g , "border" , node , prefix ) ;
2859
2868
}
2860
2869
2870
+ function splitToChunks ( array , chunkSize = CHUNKING_THRESHOLD ) {
2871
+ const chunks = [ ] ;
2872
+ for ( let i = 0 ; i < array . length ; i += chunkSize ) {
2873
+ const chunk = array . slice ( i , i + chunkSize ) ;
2874
+ chunks . push ( chunk ) ;
2875
+ }
2876
+ return chunks ;
2877
+ }
2878
+
2879
+ const CHUNKING_THRESHOLD = 65535 ;
2880
+
2881
+ function applyWithChunking ( fn , argsArray ) {
2882
+ if ( argsArray . length > CHUNKING_THRESHOLD ) {
2883
+ const chunks = splitToChunks ( argsArray ) ;
2884
+ return fn . apply ( null , chunks . map ( chunk => fn . apply ( null , chunk ) ) ) ;
2885
+ } else {
2886
+ return fn . apply ( null , argsArray ) ;
2887
+ }
2888
+ }
2889
+
2861
2890
function maxRank ( g ) {
2862
- return Math . max ( ...g . nodes ( ) . map ( v => {
2891
+ const nodes = g . nodes ( ) ;
2892
+ const nodeRanks = nodes . map ( v => {
2863
2893
let rank = g . node ( v ) . rank ;
2864
2894
if ( rank === undefined ) {
2865
2895
return Number . MIN_VALUE ;
2866
2896
}
2867
-
2868
2897
return rank ;
2869
- } ) ) ;
2898
+ } ) ;
2899
+
2900
+ return applyWithChunking ( Math . max , nodeRanks ) ;
2870
2901
}
2871
2902
2872
2903
/*
@@ -2959,7 +2990,7 @@ function zipObject(props, values) {
2959
2990
}
2960
2991
2961
2992
} , { "@dagrejs/graphlib" :29 } ] , 28 :[ function ( require , module , exports ) {
2962
- module . exports = "1.1.3 " ;
2993
+ module . exports = "1.1.4 " ;
2963
2994
2964
2995
} , { } ] , 29 :[ function ( require , module , exports ) {
2965
2996
/**
@@ -4353,7 +4384,7 @@ function read(json) {
4353
4384
}
4354
4385
4355
4386
} , { "./graph" :44 } ] , 47 :[ function ( require , module , exports ) {
4356
- module . exports = '2.2.2 ' ;
4387
+ module . exports = '2.2.3 ' ;
4357
4388
4358
4389
} , { } ] } , { } , [ 1 ] ) ( 1 )
4359
4390
} ) ;
0 commit comments