aboutsummaryrefslogtreecommitdiff
path: root/node_modules/dependency-graph/README.md
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2019-10-06 21:37:45 +0200
committerDimitri Staessens <dimitri@ouroboros.rocks>2019-10-06 21:37:45 +0200
commit3c51c3be85bb0d1bdb87ea0d6632f1c256912f27 (patch)
treec7ccc8279b12c4f7bdbbb4270d617e48f51722e4 /node_modules/dependency-graph/README.md
parent412c104bebc507bea9c94fd53b5bdc4b64cbfe31 (diff)
downloadwebsite-3c51c3be85bb0d1bdb87ea0d6632f1c256912f27.tar.gz
website-3c51c3be85bb0d1bdb87ea0d6632f1c256912f27.zip
build: Add some required modules for node
Diffstat (limited to 'node_modules/dependency-graph/README.md')
-rwxr-xr-xnode_modules/dependency-graph/README.md74
1 files changed, 74 insertions, 0 deletions
diff --git a/node_modules/dependency-graph/README.md b/node_modules/dependency-graph/README.md
new file mode 100755
index 0000000..29bdd82
--- /dev/null
+++ b/node_modules/dependency-graph/README.md
@@ -0,0 +1,74 @@
+# Dependency Graph
+
+Simple dependency graph
+
+## Overview
+
+This is a simple dependency graph useful for determining the order to do a list of things that depend on certain items being done before they are.
+
+To use, `npm install dependency-graph` and then `require('dependency-graph').DepGraph`
+
+## API
+
+### DepGraph
+
+Nodes in the graph are just simple strings with optional data associated with them.
+
+ - `addNode(name, data)` - add a node in the graph with optional data. If `data` is not given, `name` will be used as data
+ - `removeNode(name)` - remove a node from the graph
+ - `hasNode(name)` - check if a node exists in the graph
+ - `size()` - return the number of nodes in the graph
+ - `getNodeData(name)` - get the data associated with a node (will throw an Error if the node does not exist)
+ - `setNodeData(name, data)` - set the data for an existing node (will throw an Error if the node does not exist)
+ - `addDependency(from, to)` - add a dependency between two nodes (will throw an Error if one of the nodes does not exist)
+ - `removeDependency(from, to)` - remove a dependency between two nodes
+ - `clone()` - return a clone of the graph. Any data attached to the nodes will only be *shallow-copied*
+ - `dependenciesOf(name, leavesOnly)` - get an array containing the nodes that the specified node depends on (transitively). If `leavesOnly` is true, only nodes that do not depend on any other nodes will be returned in the array.
+ - `dependantsOf(name, leavesOnly)` - get an array containing the nodes that depend on the specified node (transitively). If `leavesOnly` is true, only nodes that do not have any dependants will be returned in the array.
+ - `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.
+
+Dependency Cycles are detected when running `dependenciesOf`, `dependantsOf`, and `overallOrder` and if one is found, an error will be thrown that includes what the cycle was in the message: e.g. `Dependency Cycle Found: a -> b -> c -> a`. If you wish to silence this error, pass `circular: true` when instantiating `DepGraph` (more below).
+
+## Examples
+
+ var DepGraph = require('dependency-graph').DepGraph;
+
+ var graph = new DepGraph();
+ graph.addNode('a');
+ graph.addNode('b');
+ graph.addNode('c');
+
+ graph.size() // 3
+
+ graph.addDependency('a', 'b');
+ graph.addDependency('b', 'c');
+
+ graph.dependenciesOf('a'); // ['c', 'b']
+ graph.dependenciesOf('b'); // ['c']
+ graph.dependantsOf('c'); // ['a', 'b']
+
+ graph.overallOrder(); // ['c', 'b', 'a']
+ graph.overallOrder(true); // ['c']
+
+ graph.addNode('d', 'data');
+
+ graph.getNodeData('d'); // 'data'
+
+ graph.setNodeData('d', 'newData');
+
+ graph.getNodeData('d'); // 'newData'
+
+ var circularGraph = new DepGraph({ circular: true });
+
+ circularGraph.addNode('a');
+ circularGraph.addNode('b');
+ circularGraph.addNode('c');
+ circularGraph.addNode('d');
+
+ circularGraph.addDependency('a', 'b');
+ circularGraph.addDependency('b', 'c'); // b depends on c
+ circularGraph.addDependency('c', 'a'); // c depends on a, which depends on b
+ circularGraph.addDependency('d', 'a');
+
+ circularGraph.dependenciesOf('b'); // ['a', 'c']
+ circularGraph.overallOrder(); // ['c', 'b', 'a', 'd']