Skip to content

Instantly share code, notes, and snippets.

@Clickys
Created January 26, 2019 08:34
Show Gist options
  • Save Clickys/bc8af6af89142841abb9689482add7e7 to your computer and use it in GitHub Desktop.
Save Clickys/bc8af6af89142841abb9689482add7e7 to your computer and use it in GitHub Desktop.
librarySystem with dependencies
(function(){
const libraryStorage = {}
function librarySystem(libraryName, array, callback) {
if (arguments.length > 1) {
if (array.length > 0) {
let libraryDepedencies = array.map(function(arg) {
return libraryStorage[arg];
})
libraryStorage[libraryName] = callback.apply(null, libraryDepedencies);
} else {
libraryStorage[libraryName] = callback();
}
} else {
return libraryStorage[libraryName];
}
}
window.librarySystem = librarySystem;
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment