/*! * sync-builder v0.9.0 (2014-10-18) * Wrapper to run asynchronous code in a synchronous way. * https://github.com/andrusieczko/sync-builder * * Copyright 2014 Karol Andrusieczko * Released under MIT license */ (function(){var a=function(a){var b,c=[];for(b in a)c.push(b);c.forEach(function(b){if("string"==typeof b&&"function"==typeof a[b]){var c=a[b];this[b]=function(){return this.methods.push({func:c,args:[].slice.call(arguments),ctx:a}),this}.bind(this)}}.bind(this))};a.prototype={methods:[],build:function(a,b,c){if(!this.methods.length)return a.apply(b,c),this;var d=this.methods.shift(),e=d.func.apply(d.ctx,d.args);e&&e.then?e.then(function(){this.build(a,b,c)}.bind(this)):this.build(a,b,c)}},"function"==typeof define&&define.amd?define("sync-builder",function(){return a}):"undefined"!=typeof module&&module.exports?module.exports=a:this.SyncBuilder=a}).call(this.window||this.root);