dependency-graph
Advanced tools
Comparing version 0.10.0 to 0.11.0
# Dependency Graph Changelog | ||
## 0.11.0 (March 5, 2021) | ||
- Add `entryNodes` method that returns the nodes that nothing depends on - thanks [amcdnl](https://github.com/amcdnl)! | ||
## 0.10.0 (January 9, 2021) | ||
@@ -4,0 +8,0 @@ |
@@ -327,2 +327,11 @@ /** | ||
} | ||
}, | ||
/** | ||
* Get an array of nodes that have no dependants (i.e. nothing depends on them). | ||
*/ | ||
entryNodes: function () { | ||
var self = this; | ||
return Object.keys(this.nodes).filter(function (node) { | ||
return self.incomingEdges[node].length === 0; | ||
}); | ||
} | ||
@@ -329,0 +338,0 @@ }; |
@@ -104,3 +104,3 @@ declare module 'dependency-graph' { | ||
/** | ||
* Alias of `dependentsOf` | ||
* Alias of `dependantsOf` | ||
* | ||
@@ -114,2 +114,7 @@ * @see dependantsOf | ||
/** | ||
* Get an array of nodes that have no dependants (i.e. nothing depends on them). | ||
*/ | ||
entryNodes(): string[]; | ||
/** | ||
* Construct the overall processing order for the dependency graph. If leavesOnly is true, only nodes that do not depend on any other nodes will be returned. | ||
@@ -116,0 +121,0 @@ * @param {boolean} leavesOnly |
{ | ||
"name": "dependency-graph", | ||
"description": "Simple dependency graph.", | ||
"version": "0.10.0", | ||
"version": "0.11.0", | ||
"author": "Jim Riecken <jriecken@gmail.com>", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
@@ -31,2 +31,3 @@ # Dependency Graph | ||
- `overallOrder(leavesOnly)` - construct the overall processing order for the dependency graph. If `leavesOnly` is true, only nodes that do not depend on any other nodes will be returned. | ||
- `entryNodes()` - array of nodes that have no dependants (i.e. nothing depends on them). | ||
@@ -55,2 +56,3 @@ Dependency Cycles are detected when running `dependenciesOf`, `dependantsOf`, and `overallOrder` and if one is found, a `DepGraphCycleError` will be thrown that includes what the cycle was in the message as well as the `cyclePath` property: e.g. `Dependency Cycle Found: a -> b -> c -> a`. If you wish to silence this error, pass `circular: true` when instantiating `DepGraph` (more below). | ||
graph.overallOrder(true); // ['c'] | ||
graph.entryNodes(); // ['a'] | ||
@@ -57,0 +59,0 @@ graph.addNode('d', 'data'); |
@@ -139,2 +139,15 @@ var dep_graph = require("../lib/dep_graph"); | ||
it("should find entry nodes", function () { | ||
var graph = new DepGraph(); | ||
graph.addNode("a"); | ||
graph.addNode("b"); | ||
graph.addNode("c"); | ||
graph.addDependency("a", "b"); | ||
graph.addDependency("a", "c"); | ||
expect(graph.entryNodes()).toEqual(["a"]); | ||
}); | ||
it("should throw an error if a node does not exist and a dependency is added", function () { | ||
@@ -141,0 +154,0 @@ var graph = new DepGraph(); |
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
38560
878
79