Created
July 20, 2013 02:12
-
-
Save dominictarr/6043557 to your computer and use it in GitHub Desktop.
traversals
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//traverse all modules that substack maintains. | |
//if 2nd arg is true, keep that in result set. | |
traverse(substack, false).linked("maintainers", true) | |
//traverse all modules that substack's modules depend on | |
traverse(substack, false) | |
.linked("maintainers", true) | |
.linked('resolves', true) | |
.links('depends', function depends (resolution) { | |
//notice that this function calls it self... | |
//could check if the object has many... or could | |
if(resolution.resolves) { | |
this.links('resolves', true) | |
//for other types of objects, | |
//could travel a few steps, and then loop back... | |
this.links('depends', depends) | |
} else { | |
//this is a pkg | |
//this.links('dist', true) //the tarball. | |
} | |
//keep this node in the result set. | |
return true | |
}) | |
//query all the dependencies of a module | |
traverse(moduleVersion, function M(pkg) { | |
var deps = pkg.dependencies | |
for(var module in deps) { | |
this.search(['name', module, function (version) { | |
return semver.satisfies(version, deps[module]) | |
}], M) | |
} | |
}) | |
author <-maintains- module | |
module <-resolves- resolution | |
module -dist-> tarball | |
resolution -depends-> resolution | |
a resolution is an object that describes a branch on the dependency tree | |
{ | |
resolves -> module, | |
depends: [ | |
module|resolution | |
] | |
} | |
resolves is a link to a moduleVersion | |
and depneds is an array of links to module versions, or resolution trees. | |
NAH, FUCK ALL THIS DSL CRAP. | |
JUST MAKE TRAVERSALS PROCEDURAL JS CODES. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment