Skip to content

Instantly share code, notes, and snippets.

@She-Codes
Created December 27, 2016 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save She-Codes/9776edf6a78f4fe1e59f3a7460ff10b9 to your computer and use it in GitHub Desktop.
Save She-Codes/9776edf6a78f4fe1e59f3a7460ff10b9 to your computer and use it in GitHub Desktop.
Watch and Code librarySystem with dependencies
(function() {
var libraryStorage = {};
function librarySystem(library, dependencyArray, callback) {
var libraries = [];
if ( arguments.length > 1 ) {
// go through dependencyArray and get the actual libraries
dependencyArray.forEach(function(dependency) {
libraries.push(libraryStorage[dependency]);
});
libraryStorage[library] = callback.apply(this, libraries);
} else {
return libraryStorage[library];
}
}
window.librarySystem = librarySystem;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment