Created
January 3, 2013 02:40
-
-
Save kara-ryli/4440302 to your computer and use it in GitHub Desktop.
Returns the list of modules required to load a YUI module. Doesn't manage triggers and conditionals.
This file contains hidden or 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
/*global YUI*/ | |
YUI.add("get-depenedencies", function (Y) { | |
/** | |
* Provides a method to recursively lookup YUI module dependencies | |
* | |
* @module get-depenedencies | |
*/ | |
/** | |
Retrieves the entire module dependency list for the given module. | |
@for YUI | |
@method getDependencies | |
@param name {String} The module name to look up | |
@return {Array} The dependencies required to load the module. | |
**/ | |
Y.getDependencies = function (name) { | |
var reqs = {}, | |
queue = [name], | |
module, | |
oModule; | |
do { | |
module = queue.shift(); | |
reqs[module] = true; | |
oModule = Y.Env._loader.moduleInfo[module]; | |
if (oModule && oModule.requires) | |
queue = queue.concat(oModule.requires); | |
} while (queue.length); | |
return Y.Object.keys(reqs); | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment