source: trip-planner-front/node_modules/dependency-graph/lib/index.d.ts@ 76712b2

Last change on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 3.5 KB
Line 
1declare module 'dependency-graph' {
2 export interface Options {
3 circular?: boolean;
4 }
5
6 export class DepGraph<T> {
7 /**
8 * Creates an instance of DepGraph with optional Options.
9 */
10 constructor(opts?: Options);
11
12 /**
13 * The number of nodes in the graph.
14 */
15 size(): number;
16
17 /**
18 * Add a node in the graph with optional data. If data is not given, name will be used as data.
19 * @param {string} name
20 * @param data
21 */
22 addNode(name: string, data?: T): void;
23
24 /**
25 * Remove a node from the graph.
26 * @param {string} name
27 */
28 removeNode(name: string): void;
29
30 /**
31 * Check if a node exists in the graph.
32 * @param {string} name
33 */
34 hasNode(name: string): boolean;
35
36 /**
37 * Get the data associated with a node (will throw an Error if the node does not exist).
38 * @param {string} name
39 */
40 getNodeData(name: string): T;
41
42 /**
43 * Set the data for an existing node (will throw an Error if the node does not exist).
44 * @param {string} name
45 * @param data
46 */
47 setNodeData(name: string, data?: T): void;
48
49 /**
50 * Add a dependency between two nodes (will throw an Error if one of the nodes does not exist).
51 * @param {string} from
52 * @param {string} to
53 */
54 addDependency(from: string, to: string): void;
55
56 /**
57 * Remove a dependency between two nodes.
58 * @param {string} from
59 * @param {string} to
60 */
61 removeDependency(from: string, to: string): void;
62
63 /**
64 * Return a clone of the dependency graph (If any custom data is attached
65 * to the nodes, it will only be shallow copied).
66 */
67 clone(): DepGraph<T>;
68
69 /**
70 * Get an array containing the direct dependency nodes of the specified node.
71 * @param name
72 */
73 directDependenciesOf(name: string): string[];
74
75 /**
76 * Get an array containing the nodes that directly depend on the specified node.
77 * @param name
78 */
79 directDependantsOf(name: string): string[];
80
81 /**
82 * Alias of `directDependantsOf`
83 *
84 * @see directDependantsOf
85 * @param {string} name
86 */
87 directDependentsOf(name: string): string[];
88
89 /**
90 * 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.
91 * @param {string} name
92 * @param {boolean} leavesOnly
93 */
94 dependenciesOf(name: string, leavesOnly?: boolean): string[];
95
96 /**
97 * 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.
98 * @param {string} name
99 * @param {boolean} leavesOnly
100 */
101 dependantsOf(name: string, leavesOnly?: boolean): string[];
102
103 /**
104 * Alias of `dependantsOf`
105 *
106 * @see dependantsOf
107 * @param name
108 * @param leavesOnly
109 */
110 dependentsOf(name: string, leavesOnly?: boolean): string[];
111
112 /**
113 * Get an array of nodes that have no dependants (i.e. nothing depends on them).
114 */
115 entryNodes(): string[];
116
117 /**
118 * 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.
119 * @param {boolean} leavesOnly
120 */
121 overallOrder(leavesOnly?: boolean): string[];
122 }
123
124 export class DepGraphCycleError extends Error {
125 cyclePath: string[];
126 }
127}
Note: See TracBrowser for help on using the repository browser.