cyclic-dependency-graph
A state machine that handles building a cyclic directed graph from the dependencies in a codebase.
Install
npm install --save cyclic-dependency-graph
Example
; // The files that we want to build the graph fromconst entryPoint1 = '/path/to/file_1';const entryPoint2 = '/path/to/file_2'; const graph = ; // Inform the graph that it should treat our files as entry pointsgraph;graph; graphevents; graphevents; graphevents; // Start the process of building the graphgraph;graph;
Data structures
Graph state
Stored as a flat Map
structure (using the Map implementation from immutable
).
A map structure was used primarily for simplicity and the low costs associated with node lookup and traversal.
Node
name: '...' dependencies: Set dependents: Set isEntryNode:
Diff
from: Map to: Map
Events
started
state: Map
completed
errors: Error // ... diff:
traced
node: '...' diff:
error
node: '...' error: Error diff: