Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update resolve-conflicts.js #392

Merged
merged 1 commit into from
Sep 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions lib/order/resolve-conflicts.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

var util = require("../util");
let util = require("../util");

module.exports = resolveConflicts;

Expand Down Expand Up @@ -30,9 +30,9 @@ module.exports = resolveConflicts;
* elements in `vs`.
*/
function resolveConflicts(entries, cg) {
var mappedEntries = {};
let mappedEntries = {};
entries.forEach((entry, i) => {
var tmp = mappedEntries[entry.v] = {
let tmp = mappedEntries[entry.v] = {
indegree: 0,
"in": [],
out: [],
Expand All @@ -46,21 +46,21 @@ function resolveConflicts(entries, cg) {
});

cg.edges().forEach(e => {
var entryV = mappedEntries[e.v];
var entryW = mappedEntries[e.w];
let entryV = mappedEntries[e.v];
let entryW = mappedEntries[e.w];
if (entryV !== undefined && entryW !== undefined) {
entryW.indegree++;
entryV.out.push(mappedEntries[e.w]);
}
});

var sourceSet = Object.values(mappedEntries).filter(entry => !entry.indegree);
let sourceSet = Object.values(mappedEntries).filter(entry => !entry.indegree);

return doResolveConflicts(sourceSet);
}

function doResolveConflicts(sourceSet) {
var entries = [];
let entries = [];

function handleIn(vEntry) {
return uEntry => {
Expand All @@ -85,7 +85,7 @@ function doResolveConflicts(sourceSet) {
}

while (sourceSet.length) {
var entry = sourceSet.pop();
let entry = sourceSet.pop();
entries.push(entry);
entry["in"].reverse().forEach(handleIn(entry));
entry.out.forEach(handleOut(entry));
Expand All @@ -97,8 +97,8 @@ function doResolveConflicts(sourceSet) {
}

function mergeEntries(target, source) {
var sum = 0;
var weight = 0;
let sum = 0;
let weight = 0;

if (target.weight) {
sum += target.barycenter * target.weight;
Expand Down
Loading