Skip to content

Commit 63d49aa

Browse files
committed
Bumping for release
1 parent 7c679ab commit 63d49aa

File tree

6 files changed

+93
-62
lines changed

6 files changed

+93
-62
lines changed

bower.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dagre",
3-
"version": "1.1.3",
3+
"version": "1.1.4",
44
"main": [
55
"dist/dagre.core.js"
66
],
@@ -20,6 +20,6 @@
2020
"test/**"
2121
],
2222
"dependencies": {
23-
"@dagrejs/graphlib": "2.2.2"
23+
"@dagrejs/graphlib": "2.2.3"
2424
}
2525
}

dist/dagre.js

+68-37
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ function dfsFAS(g) {
6969
let visited = {};
7070

7171
function dfs(v) {
72-
if (visited.hasOwnProperty(v)) {
72+
if (Object.hasOwn(visited, v)) {
7373
return;
7474
}
7575
visited[v] = true;
7676
stack[v] = true;
7777
g.outEdges(v).forEach(e => {
78-
if (stack.hasOwnProperty(e.w)) {
78+
if (Object.hasOwn(stack, e.w)) {
7979
fas.push(e);
8080
} else {
8181
dfs(e.w);
@@ -115,7 +115,7 @@ function addBorderSegments(g) {
115115
children.forEach(dfs);
116116
}
117117

118-
if (node.hasOwnProperty("minRank")) {
118+
if (Object.hasOwn(node, "minRank")) {
119119
node.borderLeft = [];
120120
node.borderRight = [];
121121
for (let rank = node.minRank, maxRank = node.maxRank + 1;
@@ -185,7 +185,7 @@ function reverseY(g) {
185185
g.edges().forEach(e => {
186186
let edge = g.edge(e);
187187
edge.points.forEach(reverseYOne);
188-
if (edge.hasOwnProperty("y")) {
188+
if (Object.hasOwn(edge, "y")) {
189189
reverseYOne(edge);
190190
}
191191
});
@@ -201,7 +201,7 @@ function swapXY(g) {
201201
g.edges().forEach(e => {
202202
let edge = g.edge(e);
203203
edge.points.forEach(swapXYOne);
204-
if (edge.hasOwnProperty("x")) {
204+
if (Object.hasOwn(edge, "x")) {
205205
swapXYOne(edge);
206206
}
207207
});
@@ -519,7 +519,7 @@ function updateInputGraph(inputGraph, layoutGraph) {
519519
let layoutLabel = layoutGraph.edge(e);
520520

521521
inputLabel.points = layoutLabel.points;
522-
if (layoutLabel.hasOwnProperty("x")) {
522+
if (Object.hasOwn(layoutLabel, "x")) {
523523
inputLabel.x = layoutLabel.x;
524524
inputLabel.y = layoutLabel.y;
525525
}
@@ -668,7 +668,7 @@ function translateGraph(g) {
668668
g.nodes().forEach(v => getExtremes(g.node(v)));
669669
g.edges().forEach(e => {
670670
let edge = g.edge(e);
671-
if (edge.hasOwnProperty("x")) {
671+
if (Object.hasOwn(edge, "x")) {
672672
getExtremes(edge);
673673
}
674674
});
@@ -688,8 +688,8 @@ function translateGraph(g) {
688688
p.x -= minX;
689689
p.y -= minY;
690690
});
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; }
693693
});
694694

695695
graphLabel.width = maxX - minX + marginX;
@@ -718,7 +718,7 @@ function assignNodeIntersects(g) {
718718
function fixupEdgeLabelCoords(g) {
719719
g.edges().forEach(e => {
720720
let edge = g.edge(e);
721-
if (edge.hasOwnProperty("x")) {
721+
if (Object.hasOwn(edge, "x")) {
722722
if (edge.labelpos === "l" || edge.labelpos === "r") {
723723
edge.width -= edge.labeloffset;
724724
}
@@ -873,7 +873,8 @@ module.exports = {
873873
function run(g) {
874874
let root = util.addDummyNode(g, "root", {}, "_root");
875875
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
877878
let nodeSep = 2 * height + 1;
878879

879880
g.graph().nestingRoot = root;
@@ -1195,7 +1196,7 @@ function buildLayerGraph(g, rank, relationship) {
11951196
result.setEdge(u, v, { weight: g.edge(e).weight + weight });
11961197
});
11971198

1198-
if (node.hasOwnProperty("minRank")) {
1199+
if (Object.hasOwn(node, "minRank")) {
11991200
result.setNode(v, {
12001201
borderLeft: node.borderLeft[rank],
12011202
borderRight: node.borderRight[rank]
@@ -1385,7 +1386,8 @@ module.exports = initOrder;
13851386
function initOrder(g) {
13861387
let visited = {};
13871388
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);
13891391
let layers = util.range(maxRank + 1).map(() => []);
13901392

13911393
function dfs(v) {
@@ -1545,7 +1547,7 @@ function sortSubgraph(g, v, cg, biasRight) {
15451547
if (g.children(entry.v).length) {
15461548
let subgraphResult = sortSubgraph(g, entry.v, cg, biasRight);
15471549
subgraphs[entry.v] = subgraphResult;
1548-
if (subgraphResult.hasOwnProperty("barycenter")) {
1550+
if (Object.hasOwn(subgraphResult, "barycenter")) {
15491551
mergeBarycenters(entry, subgraphResult);
15501552
}
15511553
}
@@ -1561,7 +1563,7 @@ function sortSubgraph(g, v, cg, biasRight) {
15611563
if (g.predecessors(bl).length) {
15621564
let blPred = g.node(g.predecessors(bl)[0]),
15631565
brPred = g.node(g.predecessors(br)[0]);
1564-
if (!result.hasOwnProperty("barycenter")) {
1566+
if (!Object.hasOwn(result, "barycenter")) {
15651567
result.barycenter = 0;
15661568
result.weight = 0;
15671569
}
@@ -1604,7 +1606,7 @@ module.exports = sort;
16041606

16051607
function sort(entries, biasRight) {
16061608
let parts = util.partition(entries, entry => {
1607-
return entry.hasOwnProperty("barycenter");
1609+
return Object.hasOwn(entry, "barycenter");
16081610
});
16091611
let sortable = parts.lhs,
16101612
unsortable = parts.rhs.sort((a, b) => b.i - a.i),
@@ -1896,7 +1898,7 @@ function hasConflict(conflicts, v, w) {
18961898
v = w;
18971899
w = tmp;
18981900
}
1899-
return !!conflicts[v] && conflicts[v].hasOwnProperty(w);
1901+
return !!conflicts[v] && Object.hasOwn(conflicts[v], w);
19001902
}
19011903

19021904
/*
@@ -2057,8 +2059,8 @@ function findSmallestWidthAlignment(g, xss) {
20572059
*/
20582060
function alignCoordinates(xss, alignTo) {
20592061
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);
20622064

20632065
["u", "d"].forEach(vert => {
20642066
["l", "r"].forEach(horiz => {
@@ -2068,9 +2070,9 @@ function alignCoordinates(xss, alignTo) {
20682070
if (xs === alignTo) return;
20692071

20702072
let xsVals = Object.values(xs);
2071-
let delta = alignToMin - Math.min(...xsVals);
2073+
let delta = alignToMin - util.applyWithChunking(Math.min, xsVals);
20722074
if (horiz !== "l") {
2073-
delta = alignToMax - Math.max(...xsVals);
2075+
delta = alignToMax - util.applyWithChunking(Math.max,xsVals);
20742076
}
20752077

20762078
if (delta) {
@@ -2133,7 +2135,7 @@ function sep(nodeSep, edgeSep, reverseSep) {
21332135
let delta;
21342136

21352137
sum += vLabel.width / 2;
2136-
if (vLabel.hasOwnProperty("labelpos")) {
2138+
if (Object.hasOwn(vLabel, "labelpos")) {
21372139
switch (vLabel.labelpos.toLowerCase()) {
21382140
case "l": delta = -vLabel.width / 2; break;
21392141
case "r": delta = vLabel.width / 2; break;
@@ -2148,7 +2150,7 @@ function sep(nodeSep, edgeSep, reverseSep) {
21482150
sum += (wLabel.dummy ? edgeSep : nodeSep) / 2;
21492151

21502152
sum += wLabel.width / 2;
2151-
if (wLabel.hasOwnProperty("labelpos")) {
2153+
if (Object.hasOwn(wLabel, "labelpos")) {
21522154
switch (wLabel.labelpos.toLowerCase()) {
21532155
case "l": delta = wLabel.width / 2; break;
21542156
case "r": delta = -wLabel.width / 2; break;
@@ -2483,7 +2485,7 @@ function dfsAssignLowLim(tree, visited, nextLim, v, parent) {
24832485

24842486
visited[v] = true;
24852487
tree.neighbors(v).forEach(w => {
2486-
if (!visited.hasOwnProperty(w)) {
2488+
if (!Object.hasOwn(visited, w)) {
24872489
nextLim = dfsAssignLowLim(tree, visited, nextLim, w, v);
24882490
}
24892491
});
@@ -2588,6 +2590,8 @@ function isDescendant(tree, vLabel, rootLabel) {
25882590
},{"../util":27,"./feasible-tree":23,"./util":26,"@dagrejs/graphlib":29}],26:[function(require,module,exports){
25892591
"use strict";
25902592

2593+
const { applyWithChunking } = require("../util");
2594+
25912595
module.exports = {
25922596
longestPath: longestPath,
25932597
slack: slack
@@ -2619,18 +2623,20 @@ function longestPath(g) {
26192623

26202624
function dfs(v) {
26212625
var label = g.node(v);
2622-
if (visited.hasOwnProperty(v)) {
2626+
if (Object.hasOwn(visited, v)) {
26232627
return label.rank;
26242628
}
26252629
visited[v] = true;
26262630

2627-
var rank = Math.min(...g.outEdges(v).map(e => {
2631+
let outEdgesMinLens = g.outEdges(v).map(e => {
26282632
if (e == null) {
26292633
return Number.POSITIVE_INFINITY;
26302634
}
26312635

26322636
return dfs(e.w) - g.edge(e).minlen;
2633-
}));
2637+
});
2638+
2639+
var rank = applyWithChunking(Math.min, outEdgesMinLens);
26342640

26352641
if (rank === Number.POSITIVE_INFINITY) {
26362642
rank = 0;
@@ -2650,7 +2656,7 @@ function slack(g, e) {
26502656
return g.node(e.w).rank - g.node(e.v).rank - g.edge(e).minlen;
26512657
}
26522658

2653-
},{}],27:[function(require,module,exports){
2659+
},{"../util":27}],27:[function(require,module,exports){
26542660
/* eslint "no-console": off */
26552661

26562662
"use strict";
@@ -2660,6 +2666,7 @@ let Graph = require("@dagrejs/graphlib").Graph;
26602666
module.exports = {
26612667
addBorderNode,
26622668
addDummyNode,
2669+
applyWithChunking,
26632670
asNonCompoundGraph,
26642671
buildLayerMatrix,
26652672
intersectRect,
@@ -2806,25 +2813,27 @@ function buildLayerMatrix(g) {
28062813
* rank(v) >= 0 and at least one node w has rank(w) = 0.
28072814
*/
28082815
function normalizeRanks(g) {
2809-
let min = Math.min(...g.nodes().map(v => {
2816+
let nodeRanks = g.nodes().map(v => {
28102817
let rank = g.node(v).rank;
28112818
if (rank === undefined) {
28122819
return Number.MAX_VALUE;
28132820
}
28142821

28152822
return rank;
2816-
}));
2823+
});
2824+
let min = applyWithChunking(Math.min, nodeRanks);
28172825
g.nodes().forEach(v => {
28182826
let node = g.node(v);
2819-
if (node.hasOwnProperty("rank")) {
2827+
if (Object.hasOwn(node, "rank")) {
28202828
node.rank -= min;
28212829
}
28222830
});
28232831
}
28242832

28252833
function removeEmptyRanks(g) {
28262834
// 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);
28282837

28292838
let layers = [];
28302839
g.nodes().forEach(v => {
@@ -2858,15 +2867,37 @@ function addBorderNode(g, prefix, rank, order) {
28582867
return addDummyNode(g, "border", node, prefix);
28592868
}
28602869

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+
28612890
function maxRank(g) {
2862-
return Math.max(...g.nodes().map(v => {
2891+
const nodes = g.nodes();
2892+
const nodeRanks = nodes.map(v => {
28632893
let rank = g.node(v).rank;
28642894
if (rank === undefined) {
28652895
return Number.MIN_VALUE;
28662896
}
2867-
28682897
return rank;
2869-
}));
2898+
});
2899+
2900+
return applyWithChunking(Math.max, nodeRanks);
28702901
}
28712902

28722903
/*
@@ -2959,7 +2990,7 @@ function zipObject(props, values) {
29592990
}
29602991

29612992
},{"@dagrejs/graphlib":29}],28:[function(require,module,exports){
2962-
module.exports = "1.1.3";
2993+
module.exports = "1.1.4";
29632994

29642995
},{}],29:[function(require,module,exports){
29652996
/**
@@ -4353,7 +4384,7 @@ function read(json) {
43534384
}
43544385

43554386
},{"./graph":44}],47:[function(require,module,exports){
4356-
module.exports = '2.2.2';
4387+
module.exports = '2.2.3';
43574388

43584389
},{}]},{},[1])(1)
43594390
});

0 commit comments

Comments
 (0)