Created
January 26, 2019 08:34
-
-
Save Clickys/bc8af6af89142841abb9689482add7e7 to your computer and use it in GitHub Desktop.
librarySystem with dependencies
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
(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