Skip to content

Commit

Permalink
Using Object.hasOwn instead of hasOwnProperty
Browse files Browse the repository at this point in the history
  • Loading branch information
rustedgrail committed Aug 15, 2024
1 parent 71a8f04 commit b559940
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions lib/acyclic.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ function dfsFAS(g) {
let visited = {};

function dfs(v) {
if (visited.hasOwnProperty(v)) {
if (Object.hasOwn(visited, v)) {
return;
}
visited[v] = true;
stack[v] = true;
g.outEdges(v).forEach(e => {
if (stack.hasOwnProperty(e.w)) {
if (Object.hasOwn(stack, e.w)) {
fas.push(e);
} else {
dfs(e.w);
Expand Down
2 changes: 1 addition & 1 deletion lib/add-border-segments.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function addBorderSegments(g) {
children.forEach(dfs);
}

if (node.hasOwnProperty("minRank")) {
if (Object.hasOwn(node, "minRank")) {
node.borderLeft = [];
node.borderRight = [];
for (let rank = node.minRank, maxRank = node.maxRank + 1;
Expand Down
4 changes: 2 additions & 2 deletions lib/coordinate-system.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function reverseY(g) {
g.edges().forEach(e => {
let edge = g.edge(e);
edge.points.forEach(reverseYOne);
if (edge.hasOwnProperty("y")) {
if (Object.hasOwn(edge, "y")) {
reverseYOne(edge);
}
});
Expand All @@ -57,7 +57,7 @@ function swapXY(g) {
g.edges().forEach(e => {
let edge = g.edge(e);
edge.points.forEach(swapXYOne);
if (edge.hasOwnProperty("x")) {
if (Object.hasOwn(edge, "x")) {
swapXYOne(edge);
}
});
Expand Down
10 changes: 5 additions & 5 deletions lib/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function updateInputGraph(inputGraph, layoutGraph) {
let layoutLabel = layoutGraph.edge(e);

inputLabel.points = layoutLabel.points;
if (layoutLabel.hasOwnProperty("x")) {
if (Object.hasOwn(layoutLabel, "x")) {
inputLabel.x = layoutLabel.x;
inputLabel.y = layoutLabel.y;
}
Expand Down Expand Up @@ -233,7 +233,7 @@ function translateGraph(g) {
g.nodes().forEach(v => getExtremes(g.node(v)));
g.edges().forEach(e => {
let edge = g.edge(e);
if (edge.hasOwnProperty("x")) {
if (Object.hasOwn(edge, "x")) {
getExtremes(edge);
}
});
Expand All @@ -253,8 +253,8 @@ function translateGraph(g) {
p.x -= minX;
p.y -= minY;
});
if (edge.hasOwnProperty("x")) { edge.x -= minX; }
if (edge.hasOwnProperty("y")) { edge.y -= minY; }
if (Object.hasOwn(edge, "x")) { edge.x -= minX; }
if (Object.hasOwn(edge, "y")) { edge.y -= minY; }
});

graphLabel.width = maxX - minX + marginX;
Expand Down Expand Up @@ -283,7 +283,7 @@ function assignNodeIntersects(g) {
function fixupEdgeLabelCoords(g) {
g.edges().forEach(e => {
let edge = g.edge(e);
if (edge.hasOwnProperty("x")) {
if (Object.hasOwn(edge, "x")) {
if (edge.labelpos === "l" || edge.labelpos === "r") {
edge.width -= edge.labeloffset;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/order/build-layer-graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function buildLayerGraph(g, rank, relationship) {
result.setEdge(u, v, { weight: g.edge(e).weight + weight });
});

if (node.hasOwnProperty("minRank")) {
if (Object.hasOwn(node, "minRank")) {
result.setNode(v, {
borderLeft: node.borderLeft[rank],
borderRight: node.borderRight[rank]
Expand Down
4 changes: 2 additions & 2 deletions lib/order/sort-subgraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function sortSubgraph(g, v, cg, biasRight) {
if (g.children(entry.v).length) {
let subgraphResult = sortSubgraph(g, entry.v, cg, biasRight);
subgraphs[entry.v] = subgraphResult;
if (subgraphResult.hasOwnProperty("barycenter")) {
if (Object.hasOwn(subgraphResult, "barycenter")) {
mergeBarycenters(entry, subgraphResult);
}
}
Expand All @@ -36,7 +36,7 @@ function sortSubgraph(g, v, cg, biasRight) {
if (g.predecessors(bl).length) {
let blPred = g.node(g.predecessors(bl)[0]),
brPred = g.node(g.predecessors(br)[0]);
if (!result.hasOwnProperty("barycenter")) {
if (!Object.hasOwn(result, "barycenter")) {
result.barycenter = 0;
result.weight = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/order/sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = sort;

function sort(entries, biasRight) {
let parts = util.partition(entries, entry => {
return entry.hasOwnProperty("barycenter");
return Object.hasOwn(entry, "barycenter");
});
let sortable = parts.lhs,
unsortable = parts.rhs.sort((a, b) => b.i - a.i),
Expand Down
6 changes: 3 additions & 3 deletions lib/position/bk.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ function hasConflict(conflicts, v, w) {
v = w;
w = tmp;
}
return !!conflicts[v] && conflicts[v].hasOwnProperty(w);
return !!conflicts[v] && Object.hasOwn(conflicts[v], w);
}

/*
Expand Down Expand Up @@ -389,7 +389,7 @@ function sep(nodeSep, edgeSep, reverseSep) {
let delta;

sum += vLabel.width / 2;
if (vLabel.hasOwnProperty("labelpos")) {
if (Object.hasOwn(vLabel, "labelpos")) {
switch (vLabel.labelpos.toLowerCase()) {
case "l": delta = -vLabel.width / 2; break;
case "r": delta = vLabel.width / 2; break;
Expand All @@ -404,7 +404,7 @@ function sep(nodeSep, edgeSep, reverseSep) {
sum += (wLabel.dummy ? edgeSep : nodeSep) / 2;

sum += wLabel.width / 2;
if (wLabel.hasOwnProperty("labelpos")) {
if (Object.hasOwn(wLabel, "labelpos")) {
switch (wLabel.labelpos.toLowerCase()) {
case "l": delta = wLabel.width / 2; break;
case "r": delta = -wLabel.width / 2; break;
Expand Down
2 changes: 1 addition & 1 deletion lib/rank/network-simplex.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function dfsAssignLowLim(tree, visited, nextLim, v, parent) {

visited[v] = true;
tree.neighbors(v).forEach(w => {
if (!visited.hasOwnProperty(w)) {
if (!Object.hasOwn(visited, w)) {
nextLim = dfsAssignLowLim(tree, visited, nextLim, w, v);
}
});
Expand Down
2 changes: 1 addition & 1 deletion lib/rank/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function longestPath(g) {

function dfs(v) {
var label = g.node(v);
if (visited.hasOwnProperty(v)) {
if (Object.hasOwn(visited, v)) {
return label.rank;
}
visited[v] = true;
Expand Down
2 changes: 1 addition & 1 deletion lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ function normalizeRanks(g) {
let min = applyWithChunking(Math.min, nodeRanks);
g.nodes().forEach(v => {
let node = g.node(v);
if (node.hasOwnProperty("rank")) {
if (Object.hasOwn(node, "rank")) {
node.rank -= min;
}
});
Expand Down

0 comments on commit b559940

Please # to comment.