-
Notifications
You must be signed in to change notification settings - Fork 2
/
deference.min.js
1 lines (1 loc) · 1.49 KB
/
deference.min.js
1
!function(){var a;a="undefined"!=typeof require&&null!==require?require("jquery"):this.jQuery,a.extend({parallel:function(b,c,d){return a.Deferred(function(a){var e=0,f=0,g=[];if(d="undefined"!=typeof d?d:{},threshhold="undefined"!=typeof d.threshhold?d.threshhold:0,b.length>0)for(var h=0;h<b.length;h++)c(b[h]).done(function(){e++,a.notify(e,b.length,100*(e/b.length)),e==b.length&&a.resolve.apply(a,arguments)}).fail(function(b){f++,e++,"undefined"!=typeof b&&(g.push(b),arguments[0]=g),f>threshhold&&a.reject.apply(a,arguments)});else a.resolve();return a.promise()})},serial:function(b,c,d){d="undefined"!=typeof d?d:{},d.threshhold="undefined"!=typeof d.threshhold?d.threshhold:0,d.index="undefined"!=typeof d.index?d.index:0,d.deferred="undefined"!=typeof d.deferred?d.deferred:a.Deferred(),d.failures="undefined"!=typeof d.failures?d.failures:0,d.failure_objects="undefined"!=typeof d.failure_objects?d.failure_objects:[];var e=function(){d.index++,d.deferred.notify(d.index,b.length,100*(d.index/b.length)),d.index==b.length?d.deferred.resolve.apply(d.deferred,arguments):a.serial(b,c,d)};return b.length>0?b[d.index]&&c(b[d.index]).done(function(){e()}).fail(function(a){d.failures++,"undefined"!=typeof a&&(d.failure_objects.push(a),arguments[0]=d.failure_objects),d.failures>d.threshhold?d.deferred.reject.apply(d.deferred,arguments):e()}):d.deferred.resolve(),d.deferred.promise()},wait:function(b){return null==b&&(b=1e3),a.Deferred(function(a){setTimeout(function(){a.resolve()},b)}).promise()}})}.call(this);