promise-pool-ext
Advanced tools
Comparing version 1.2.4 to 1.2.5
@@ -1,21 +0,31 @@ | ||
module.exports = graph => { | ||
const nodes = new Set(Object.keys(graph)); | ||
module.exports = G => { | ||
const pending = new Set(Object.keys(G)); | ||
const searchCycle = (trace, node) => { | ||
const cycleStartIdx = trace.indexOf(node); | ||
while (pending.size !== 0) { | ||
const trace = [pending.values().next().value]; | ||
const parentIdx = [0]; | ||
pending.delete(trace[0]); | ||
if (cycleStartIdx !== -1) { | ||
throw new Error(`Cycle detected: ${trace.slice(cycleStartIdx).concat(node).join(' <- ')}`); | ||
} | ||
while (trace.length !== 0) { | ||
const lastIdx = trace.length - 1; | ||
const parent = G[trace[lastIdx]][parentIdx[lastIdx]]; | ||
if (nodes.delete(node) === true) { | ||
const nextTrace = trace.concat(node); | ||
graph[node].forEach(nextNode => searchCycle(nextTrace, nextNode)); | ||
if (parent === undefined) { | ||
trace.pop(); | ||
parentIdx.pop(); | ||
} else { | ||
if (trace.includes(parent)) { | ||
throw new Error(`Cycle detected: ${trace.slice(trace.indexOf(parent)).concat(parent).join(' <- ')}`); | ||
} | ||
parentIdx[lastIdx] += 1; | ||
if (pending.delete(parent)) { | ||
trace.push(parent); | ||
parentIdx.push(0); | ||
} | ||
} | ||
} | ||
}; | ||
while (nodes.size !== 0) { | ||
searchCycle([], nodes.values().next().value); | ||
} | ||
}; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlsL2NoZWNrLWN5Y2xpYy5qcyJdLCJuYW1lcyI6WyJtb2R1bGUiLCJleHBvcnRzIiwiZ3JhcGgiLCJub2RlcyIsIlNldCIsIk9iamVjdCIsImtleXMiLCJzZWFyY2hDeWNsZSIsInRyYWNlIiwibm9kZSIsImN5Y2xlU3RhcnRJZHgiLCJpbmRleE9mIiwiRXJyb3IiLCJzbGljZSIsImNvbmNhdCIsImpvaW4iLCJkZWxldGUiLCJuZXh0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gaWYgKHBhcmVudCA9PT0gdW5kZWZpbmVkKSB7XG4gICAgICAgIHRyYWNlLnBvcCgpO1xuICAgICAgICBwYXJlbnRJZHgucG9wKCk7XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBpZiAodHJhY2UuaW5jbHVkZXMocGFyZW50KSkge1xuICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgQ3ljbGUgZGV0ZWN0ZWQ6ICR7dHJhY2VcbiAgICAgICAgICAgIC5zbGljZSh0cmFjZS5pbmRleE9mKHBhcmVudCkpLmNvbmNhdChwYXJlbnQpLmpvaW4oJyA8LSAnKX1gKTtcbiAgICAgICAgfVxuICAgICAgICBwYXJlbnRJZHhbbGFzdElkeF0gKz0gMTtcbiAgICAgICAgaWYgKHBlbmRpbmcuZGVsZXRlKHBhcmVudCkpIHtcbiAgICAgICAgICB0cmFjZS5wdXNoKHBhcmVudCk7XG4gICAgICAgICAgcGFyZW50SWR4LnB1c2goMCk7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9XG4gIH1cbn07XG4iXX0= |
{ | ||
"name": "promise-pool-ext", | ||
"version": "1.2.4", | ||
"version": "1.2.5", | ||
"main": "lib/index.js", | ||
@@ -23,3 +23,3 @@ "repository": { | ||
"eslint-config-airbnb-base": "14.1.0", | ||
"eslint-plugin-import": "2.20.1", | ||
"eslint-plugin-import": "2.20.2", | ||
"eslint-plugin-json": "2.1.1", | ||
@@ -31,2 +31,3 @@ "eslint-plugin-markdown": "1.0.2", | ||
"nyc": "15.0.0", | ||
"random-dag": "1.0.4", | ||
"semantic-release": "17.0.4" | ||
@@ -33,0 +34,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25583
131
20