Created
September 3, 2019 02:18
-
-
Save EmbraceLife/be15bec729cbac3b96040ccade88aefb to your computer and use it in GitHub Desktop.
runWithDebugger added dependencies
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
(function createLibrarySystems(){ | |
var libraryStorage = {}; | |
function librarySystem(libraryName, dependenciesArray, callback){ | |
if (arguments.length > 1){ | |
if (dependenciesArray.length > 0) { | |
var dependencyLibs = dependenciesArray.map(function(dep){ | |
return libraryStorage[dep]; | |
}) | |
libraryStorage[libraryName] = callback.apply(this, dependencyLibs); | |
} else { | |
libraryStorage[libraryName] = callback(); | |
} | |
} else { | |
return libraryStorage[libraryName]; | |
} | |
} | |
// debugger; | |
// librarySystem('name', [], function() { | |
// return 'Gordon'; | |
// }); | |
// librarySystem('company', [], function() { | |
// return 'Watch and Code'; | |
// }); | |
// librarySystem('workBlurb', ['name', 'company'], function(name, company) { | |
// return name + ' works at ' + company; | |
// }); | |
// librarySystem('workBlurb'); // 'Gordon works at Watch and Code' | |
window.myLibs = librarySystem; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment