Skip to content

Instantly share code, notes, and snippets.

View naf03's full-sized avatar

Alex naf03

View GitHub Profile
@naf03
naf03 / gist:758cb2ee3d8ba652e24d881048ced8b6
Created April 7, 2019 05:37
Improved runWithDebugger function
function runWithDebugger(callback, optionalArgs){
//check optionalArgs is undefined
if (optionalArgs===undefined){
debugger;
callback();
}
else if ( Object.getPrototypeOf(optionalArgs)===Array.prototype ){
debugger;
callback.apply(null, optionalArgs);
}
@naf03
naf03 / gist:0951ad6c040656fec9b096a85217e299
Last active April 9, 2019 10:09
librarySystem with dependencies
(function(){
var libraryStorage = {};
function librarySystem(libraryName, dependencies,callback){
if (arguments.length===1){
return libraryStorage[libraryName];
} else if (arguments.length>1){
if (dependencies.length===0){
libraryStorage[libraryName]=callback();
} else {
var dependentLibraries = dependencies.map(function(dependency){