{"id":13725271,"url":"https://github.com/jriecken/dependency-graph","last_synced_at":"2025-05-14T23:07:30.435Z","repository":{"id":8528080,"uuid":"10144833","full_name":"jriecken/dependency-graph","owner":"jriecken","description":"A simple dependency graph for Node.js","archived":false,"fork":false,"pushed_at":"2024-01-31T23:00:14.000Z","size":90,"stargazers_count":341,"open_issues_count":6,"forks_count":47,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-05-07T12:45:39.335Z","etag":null,"topics":["dependency-graph","graph","javascript"],"latest_commit_sha":null,"homepage":"http://jriecken.github.io/dependency-graph/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jriecken.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-05-18T17:46:07.000Z","updated_at":"2025-05-02T19:54:04.000Z","dependencies_parsed_at":"2024-06-18T12:26:44.892Z","dependency_job_id":null,"html_url":"https://github.com/jriecken/dependency-graph","commit_stats":{"total_commits":52,"total_committers":11,"mean_commits":"4.7272727272727275","dds":0.3076923076923077,"last_synced_commit":"a9eb7aa253b857ec7652dddefb48a350af787ef4"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jriecken%2Fdependency-graph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jriecken%2Fdependency-graph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jriecken%2Fdependency-graph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jriecken%2Fdependency-graph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jriecken","download_url":"https://codeload.github.com/jriecken/dependency-graph/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253411191,"owners_count":21904134,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dependency-graph","graph","javascript"],"created_at":"2024-08-03T01:02:17.837Z","updated_at":"2025-05-14T23:07:25.427Z","avatar_url":"https://github.com/jriecken.png","language":"JavaScript","readme":"# Dependency Graph\n\nSimple dependency graph\n\n## Overview\n\nThis 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.\n\nTo use, `npm install dependency-graph` and then `require('dependency-graph').DepGraph`\n\n## API\n\n### DepGraph\n\nNodes in the graph are just simple strings with optional data associated with them.\n\n - `addNode(name, data)` - add a node in the graph with optional data. If `data` is not given, `name` will be used as data\n - `removeNode(name)` - remove a node from the graph\n - `hasNode(name)` - check if a node exists in the graph\n - `size()` - return the number of nodes in the graph\n - `getNodeData(name)` - get the data associated with a node (will throw an `Error` if the node does not exist)\n - `setNodeData(name, data)` - set the data for an existing node (will throw an `Error` if the node does not exist)\n - `addDependency(from, to)` - add a dependency between two nodes (will throw an `Error` if one of the nodes does not exist)\n - `removeDependency(from, to)` - remove a dependency between two nodes\n - `clone()` - return a clone of the graph. Any data attached to the nodes will only be *shallow-copied*\n - `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.\n - `dependantsOf(name, leavesOnly)` (aliased as `dependentsOf`) - 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.\n - `directDependenciesOf(name)` - get an array containing the direct dependencies of the specified node\n - `directDependantsOf(name)` (aliased as `directDependentsOf`) - get an array containing the nodes that directly depend on the specified node\n - `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.\n - `entryNodes()` - array of nodes that have no dependants (i.e. nothing depends on them).\n\nDependency 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 -\u003e b -\u003e c -\u003e a`. If you wish to silence this error, pass `circular: true` when instantiating `DepGraph` (more below).\n\n## Examples\n\n    var DepGraph = require('dependency-graph').DepGraph;\n\n    var graph = new DepGraph();\n    graph.addNode('a');\n    graph.addNode('b');\n    graph.addNode('c');\n\n    graph.size() // 3\n\n    graph.addDependency('a', 'b');\n    graph.addDependency('b', 'c');\n\n    graph.dependenciesOf('a'); // ['c', 'b']\n    graph.dependenciesOf('b'); // ['c']\n    graph.dependantsOf('c'); // ['a', 'b']\n\n    graph.overallOrder(); // ['c', 'b', 'a']\n    graph.overallOrder(true); // ['c']\n    graph.entryNodes(); // ['a']\n\n    graph.addNode('d', 'data');\n\n    graph.getNodeData('d'); // 'data'\n\n    graph.setNodeData('d', 'newData');\n\n    graph.getNodeData('d'); // 'newData'\n\n    var circularGraph = new DepGraph({ circular: true });\n\n    circularGraph.addNode('a');\n    circularGraph.addNode('b');\n    circularGraph.addNode('c');\n    circularGraph.addNode('d');\n\n    circularGraph.addDependency('a', 'b');\n    circularGraph.addDependency('b', 'c'); // b depends on c\n    circularGraph.addDependency('c', 'a'); // c depends on a, which depends on b\n    circularGraph.addDependency('d', 'a');\n\n    circularGraph.dependenciesOf('b'); // ['a', 'c']\n    circularGraph.overallOrder(); // ['c', 'b', 'a', 'd']\n","funding_links":[],"categories":["javascript","JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjriecken%2Fdependency-graph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjriecken%2Fdependency-graph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjriecken%2Fdependency-graph/lists"}