Comparing version
32
index.js
@@ -30,8 +30,6 @@ const promise = require('bluebird'); | ||
// format a node in a dependency graph after all dependencies are resolved | ||
Deptrace.prototype.format = function (input, children, allNodes) { | ||
return promise.resolve({ | ||
label: input.name, | ||
children: children, | ||
nodes: allNodes | ||
}); | ||
Deptrace.prototype.format = function (input, nodes) { | ||
input.label = input.name; | ||
input.nodes = nodes; | ||
return promise.resolve(input); | ||
}; | ||
@@ -45,2 +43,11 @@ | ||
parents.push(input); | ||
var recurse = this._recurse(input, parents); | ||
if (arguments.length === 1) { | ||
recurse = recurse.then(this.format.bind(this, input)); | ||
} | ||
return recurse; | ||
}; | ||
Deptrace.prototype._recurse = function (input, parents) { | ||
return this.depsFor(input). | ||
@@ -50,15 +57,8 @@ map(function (dep) { | ||
}.bind(this)). | ||
then(this._recurse.bind(this, input, parents)); | ||
}; | ||
Deptrace.prototype._recurse = function (input, parents, deps) { | ||
// we lose the resolved version of each dep here because we | ||
// replace each dependency with the graphed version of itself | ||
return promise.resolve(deps). | ||
map(function (dep) { | ||
return this.graph(dep, parents); | ||
}.bind(this)). | ||
then(this.format.bind(this, input, deps)); | ||
return this.graph(dep, parents). | ||
then(this.format.bind(this, dep)); | ||
}.bind(this)); | ||
}; | ||
Deptrace.packageJson = require('./lib/package_json'); |
{ | ||
"name": "deptrace", | ||
"description": "Trace and format recursive dependency trees asynchronously.", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"homepage": "https://github.com/tkellen/node-deptrace", | ||
@@ -6,0 +6,0 @@ "authors": [ |
@@ -94,3 +94,3 @@ # deptrace [](http://travis-ci.org/tkellen/node-deptrace) | ||
#### opts.format(input, children, allNodes) | ||
#### opts.format(input, nodes) | ||
@@ -97,0 +97,0 @@ This method can be used to format the result for each node of the graph after all of its direct dependencies have been resolved. |
Sorry, the diff of this file is not supported yet
9172
-1.09%68
-1.45%