brototype - Bro, do you even?

  •        0

You've got a deeply-nested set of objects that may or may not always be there.We've all seen something like this:`var myURL = app.config.environment.buildURL('dev');`which leads to one of our favorite javascript errors...`error: undefined is not a function`And the solution only makes the code base ugly:```jsvar myURL;if (app && app.config && app.config.environment && app.config.environment.buildURL) { myURL = app.config.environment.buildURL('dev');}```We all hate that, don't we?So what if you could just type:```jsvar myURL;if (Bro(app).doYouEven('config.environment.buildURL')) { myURL = app.config.environment.buildURL('dev');}```Or better yet, how about:```jsvar myURL;Bro(app) .iDontAlways('config.environment.buildURL') .butWhenIdo(function(buildURL){ myURL = buildURL('dev'); });```Well, now you can!But what if you have something like this:```jsapp['soap:Envelope']['soap:Body'][0].getResponse[0]['rval'][0].customerId[0]```We got you covered.```jsif (Bro(app).doYouEven("soap:Envelope.soap:Body.0.getResponse.0.rval.0.customerId.0")) { var thisVar = app['soap:Envelope']['soap:Body'][0].getResponse[0]['rval'][0].customerId[0];}```



Related Projects