Comparing version 0.4.0 to 0.4.1
115
lib/async.js
@@ -441,6 +441,7 @@ (function() { | ||
_times(limit, function(n) { | ||
if (beforeCompleted + n >= size) { | ||
var index = beforeCompleted + n; | ||
if (index >= size) { | ||
return; | ||
} | ||
_iterator(collection[beforeCompleted + n], once(done)); | ||
_iterator(collection[index], once(done)); | ||
}); | ||
@@ -456,6 +457,7 @@ }; | ||
_times(limit, function(n) { | ||
if (beforeCompleted + n >= size) { | ||
var index = beforeCompleted + n; | ||
if (index >= size) { | ||
return; | ||
} | ||
_iterator(collection[keys[beforeCompleted + n]], once(done)); | ||
_iterator(collection[keys[index]], once(done)); | ||
}); | ||
@@ -622,6 +624,6 @@ }; | ||
_times(limit, function(n) { | ||
if (beforeCompleted + n >= size) { | ||
var index = beforeCompleted + n; | ||
if (index >= size) { | ||
return; | ||
} | ||
var index = beforeCompleted + n; | ||
_iterator(collection[index], createCallback(index)); | ||
@@ -639,6 +641,6 @@ }); | ||
_times(limit, function(n) { | ||
if (beforeCompleted + n >= size) { | ||
var index = beforeCompleted + n; | ||
if (index >= size) { | ||
return; | ||
} | ||
var index = beforeCompleted + n; | ||
_iterator(collection[keys[index]], createCallback(index)); | ||
@@ -890,6 +892,6 @@ }); | ||
_times(limit, function(n) { | ||
if (beforeCompleted + n >= size) { | ||
var index = beforeCompleted + n; | ||
if (index >= size) { | ||
return; | ||
} | ||
var index = beforeCompleted + n; | ||
var item = collection[index]; | ||
@@ -907,6 +909,6 @@ _iterator(item, once(createCallback(item))); | ||
_times(limit, function(n) { | ||
if (beforeCompleted + n >= size) { | ||
var index = beforeCompleted + n; | ||
if (index >= size) { | ||
return; | ||
} | ||
var index = beforeCompleted + n; | ||
var item = collection[keys[index]]; | ||
@@ -1140,8 +1142,8 @@ _iterator(item, once(createCallback(item))); | ||
_times(limit, function(n) { | ||
if (beforeCompleted + n >= size) { | ||
var index = beforeCompleted + n; | ||
if (index >= size) { | ||
return; | ||
} | ||
var index = beforeCompleted + n; | ||
var item = collection[index]; | ||
_iterator(item, once(createCallback(index, item))); | ||
_iterator(item, createCallback(index, item)); | ||
}); | ||
@@ -1157,9 +1159,9 @@ }; | ||
_times(limit, function(n) { | ||
if (beforeCompleted + n >= size) { | ||
var index = beforeCompleted + n; | ||
if (index >= size) { | ||
return; | ||
} | ||
var index = beforeCompleted + n; | ||
var key = keys[index]; | ||
var item = collection[key]; | ||
_iterator(item, once(createCallback(key, item))); | ||
_iterator(item, createCallback(key, item)); | ||
}); | ||
@@ -1177,4 +1179,10 @@ }; | ||
var called = false; | ||
return function(bool) { | ||
if (called) { | ||
throw new Error('Callback was already called.'); | ||
} | ||
called = true; | ||
if (!bool) { | ||
@@ -1195,4 +1203,11 @@ result[key + ''] = item; | ||
var called = false; | ||
return function(bool) { | ||
if (called) { | ||
throw new Error('Callback was already called.'); | ||
} | ||
called = true; | ||
if (bool) { | ||
@@ -1432,6 +1447,6 @@ result[key + ''] = item; | ||
_times(limit, function(n) { | ||
if (beforeCompleted + n >= size) { | ||
var index = beforeCompleted + n; | ||
if (index >= size) { | ||
return; | ||
} | ||
var index = beforeCompleted + n; | ||
_iterator(result, collection[index], index, once(done)); | ||
@@ -1448,6 +1463,6 @@ }); | ||
_times(limit, function(n) { | ||
if (beforeCompleted + n >= size) { | ||
var index = beforeCompleted + n; | ||
if (index >= size) { | ||
return; | ||
} | ||
var index = beforeCompleted + n; | ||
var key = keys[index]; | ||
@@ -1553,2 +1568,4 @@ _iterator(result, collection[key], key, once(done)); | ||
function done(res) { | ||
callback = callback || function() {}; | ||
callback(!!res); | ||
@@ -1563,2 +1580,4 @@ } | ||
function done(res) { | ||
callback = callback || function() {}; | ||
callback(!!res); | ||
@@ -1573,2 +1592,4 @@ } | ||
function done(res) { | ||
callback = callback || function() {}; | ||
callback(!!res); | ||
@@ -1722,6 +1743,6 @@ } | ||
_times(limit, function(n) { | ||
if (beforeCompleted + n >= size) { | ||
var index = beforeCompleted + n; | ||
if (index >= size) { | ||
return; | ||
} | ||
var index = beforeCompleted + n; | ||
_iterator(collection[index], once(done)); | ||
@@ -1738,6 +1759,6 @@ }); | ||
_times(limit, function(n) { | ||
if (beforeCompleted + n >= size) { | ||
var index = beforeCompleted + n; | ||
if (index >= size) { | ||
return; | ||
} | ||
var index = beforeCompleted + n; | ||
_iterator(collection[keys[index]], once(done)); | ||
@@ -1824,3 +1845,3 @@ }); | ||
} | ||
}; | ||
}; | ||
} | ||
@@ -1866,2 +1887,3 @@ | ||
callback = callback || function() {}; | ||
var iterator = createIterator(); | ||
@@ -2564,9 +2586,7 @@ reduce(tasks, {}, iterator, function(err, memo) { | ||
var called = false; | ||
var completed = 0; | ||
var _iterator = thisArg ? iterator.bind(thisArg) : iterator; | ||
_times(n, function(num) { | ||
_iterator(num, once(createCallback(num))); | ||
_iterator(num, createCallback(num)); | ||
}); | ||
@@ -2576,15 +2596,19 @@ | ||
var called = false; | ||
return function(err, res) { | ||
if (called) { | ||
return; | ||
throw new Error('Callback was already called.'); | ||
} | ||
called = true; | ||
result[index] = res; | ||
if (err) { | ||
called = true; | ||
return callback(err); | ||
callback(err); | ||
callback = function() {}; | ||
return; | ||
} | ||
if (++completed >= n) { | ||
called = true; | ||
callback(null, result); | ||
callback = function() {}; | ||
} | ||
@@ -2644,6 +2668,4 @@ }; | ||
var called = false; | ||
var completed = 0; | ||
var beforeCompleted = 0; | ||
var _iterator = thisArg ? iterator.bind(thisArg) : iterator; | ||
@@ -2653,7 +2675,7 @@ | ||
_times(limit, function(num) { | ||
if (beforeCompleted + num >= n) { | ||
var index = beforeCompleted + num; | ||
if (index >= n) { | ||
return; | ||
} | ||
var index = beforeCompleted + num; | ||
_iterator(index, once(createCallback(index))); | ||
_iterator(index, createCallback(index)); | ||
}); | ||
@@ -2665,16 +2687,21 @@ }; | ||
var called = false; | ||
return function(err, res) { | ||
if (called) { | ||
return; | ||
throw new Error('Callback was already called.'); | ||
} | ||
called = true; | ||
result[index] = res; | ||
if (err) { | ||
called = true; | ||
return callback(err); | ||
callback(err); | ||
callback = function() {}; | ||
return; | ||
} | ||
if (++completed >= n) { | ||
called = true; | ||
return callback(null, result); | ||
callback(null, result); | ||
callback = function() {}; | ||
return; | ||
} | ||
@@ -2681,0 +2708,0 @@ if (completed >= beforeCompleted + limit) { |
(function(){function t(b){for(var d=Object.keys(b),a=-1,c=d.length,e=Array(c);++a<c;)e[a]=b[d[a]];return e}function E(b){for(var d=-1,a=b.length,c=Array(a);++d<a;)c[d]=b[d];return c}function u(b,d){var a=-1,c=b.length-d;if(0>=c)return[];for(var e=Array(c);++a<c;)e[a]=b[a+d];return e}function la(b){for(var d=-1,a=b.length,c=Array(a);++d<a;)c[a-d-1]=b[d];return c}function s(b,d){for(var a=-1,c=b.length;++a<c;)d(b[a],a,b);return b}function v(b,d,a){a=a||Object.keys(b);for(var c=-1,e=a.length;++c<e;){var f= | ||
a[c];d(b[f],f,b)}return b}function ma(b,d){return Array.isArray(b)?s(b,d):v(b,d)}function r(b,d){for(var a=-1;++a<b;)d(a)}function T(b,d){for(var a=b.length,c=-1;++c<a;)if(!d(b[c]))return!1;return!0}function w(b){for(var d=b.length,a=-1,c=Array(d);++a<d;)c[a]=b[a];return c}function z(b){for(var d=Object.keys(b),a=d.length,c=-1,e={};++c<a;){var f=d[c];e[f]=b[f]}return e}function U(b,d){for(var a=-1,c=b.length,e=Array(c);++a<c;)e[a]=(b[a]||{})[d];return e}function q(b){var d=!1;return function(a,c){if(d){if(a)return b(a, | ||
c);throw Error("Callback was already called.");}d=!0;b(a,c)}}function G(b,d,a,c){function e(b,c){b?(a(b),a=function(){}):!1===c?(a(),a=function(){}):++g>=f&&(a(),a=function(){})}a=a||function(){};var f,g=0,k=c?d.bind(c):d;d=function(a){k(a,q(e))};if(Array.isArray(b)){f=b.length;if(!f)return a();s(b,d)}else{c=Object.keys(b);f=c.length;if(!f)return a();v(b,d,c)}}function H(b,d,a,c){function e(b,c){if(k)throw Error("Callback was already called.");k=!0;if(b)return a(b);if(++h>=f||!1===c)return a();g()} | ||
a=a||function(){};var f,g,k,h=0,l=c?d.bind(c):d;if(Array.isArray(b)){f=b.length;if(!f)return a();g=function(){k=!1;l(b[h],e)}}else{var m=Object.keys(b);f=m.length;if(!f)return a();g=function(){k=!1;l(b[m[h]],e)}}g()}function V(b,d,a,c,e){function f(a,b){a?(c(a),c=function(){}):++h>=g?(c(),c=function(){}):!1===b?(c(),c=function(){}):h>=l+d&&(l=h,k())}c=c||function(){};var g,k,h=0,l=0,m=e?a.bind(e):a;if(Array.isArray(b)){g=b.length;if(!g)return c();k=function(){r(d,function(a){l+a>=g||m(b[l+a],q(f))})}}else{var n= | ||
Object.keys(b);g=n.length;if(!g)return c();k=function(){r(d,function(a){l+a>=g||m(b[n[l+a]],q(f))})}}k()}function W(b,d,a,c){function e(b){var c=!1;return function(e,d){if(c)throw Error("Callback was already called.");c=!0;g[b]=d;e?(a(e,w(g)),a=function(){}):++h>=f&&(a(null,g),a=function(){})}}a=a||function(){};var f,g,k=0,h=0,l=c?d.bind(c):d;d=function(a){l(a,e(k++))};if(Array.isArray(b)){f=b.length;g=Array(f);if(!f)return a(null,g);s(b,d)}else{c=Object.keys(b);f=c.length;g=Array(f);if(!f)return a(null, | ||
g);v(b,d,c)}}function X(b,d,a,c){function e(b){var c=!1;return function(e,d){if(c)throw Error("Callback was already called.");c=!0;g[b]=d;e?(a(e,w(g)),a=function(){}):++h>=f?(a(null,g),a=function(){}):k()}}a=a||function(){};var f,g,k,h=0,l=c?d.bind(c):d;if(Array.isArray(b)){f=b.length;g=Array(f);if(!f)return a(null,g);k=function(){l(b[h],e(h))}}else{var m=Object.keys(b);f=m.length;g=Array(f);if(!f)return a(null,g);k=function(){l(b[m[h]],e(h))}}k()}function Z(b,d,a,c,e){function f(a){var b=!1;return function(e, | ||
f){if(b)throw Error("Callback was already called.");b=!0;k[a]=f;e?(c(e,w(k)),c=function(){}):++l>=g?(c(null,k),c=function(){}):l>=m+d&&(m=l,h())}}c=c||function(){};var g,k,h,l=0,m=0,n=e?a.bind(e):a;if(Array.isArray(b)){g=b.length;k=Array(g);if(!g)return c(null,k);h=function(){r(d,function(a){m+a>=g||(a=m+a,n(b[a],f(a)))})}}else{var p=Object.keys(b);g=p.length;k=Array(g);if(!g)return c(null,k);h=function(){r(d,function(a){m+a>=g||(a=m+a,n(b[p[a]],f(a)))})}}h()}function $(b,d,a,c){I(b,d,function(c){a= | ||
a||function(){};a(Array.isArray(b)?c:t(c))},c)}function aa(b,d,a,c){J(b,d,function(c){a=a||function(){};a(Array.isArray(b)?c:t(c))},c)}function ba(b,d,a,c,e){K(b,d,a,function(a){c=c||function(){};c(Array.isArray(b)?a:t(a))},e)}function L(b,d,a,c,e){a=a||function(){};var f,g=0,k=function(){function b(c){return function(b){b?++g>=f&&(a(),a=function(){}):(a(c),a=function(){})}}function c(b){return function(c){c?(a(b),a=function(){}):++g>=f&&(a(),a=function(){})}}return e?b:c}(),h=c?d.bind(c):d;d=function(a){h(a, | ||
k(a))};if(Array.isArray(b)){f=b.length;if(!f)return a();s(b,d)}else{f=Object.keys(b).length;if(!f)return a();v(b,d)}}function M(b,d,a,c,e){a=a||function(){};var f,g,k,h=0,l=function(){function b(c){return function(b){if(k)throw Error("Callback was already called.");k=!0;if(!b)return a(c);if(++h>=f)return a();g()}}function c(b){return function(c){if(k)throw Error("Callback was already called.");k=!0;if(c)return a(b);if(++h>=f)return a();g()}}return e?b:c}(),m=c?d.bind(c):d;if(Array.isArray(b)){f=b.length; | ||
if(!f)return a();g=function(){k=!1;var a=b[h];m(a,l(a))}}else{var n=Object.keys(b);f=n.length;if(!f)return a();g=function(){k=!1;var a=b[n[h]];m(a,l(a))}}g()}function N(b,d,a,c,e,f){c=c||function(){};var g,k,h=0,l=0,m=function(){function a(b){return function(a){a?++h>=g?(c(),c=function(){}):h>=l+d&&(l=h,k()):(c(b),c=function(){})}}function b(a){return function(b){b?(c(a),c=function(){}):++h>=g?(c(),c=function(){}):h>=l+d&&(l=h,k())}}return f?a:b}(),n=e?a.bind(e):a;if(Array.isArray(b)){g=b.length; | ||
if(!g)return c();k=function(){r(d,function(a){l+a>=g||(a=b[l+a],n(a,q(m(a))))})}}else{var p=Object.keys(b);g=p.length;if(!g)return c();k=function(){r(d,function(a){l+a>=g||(a=b[p[l+a]],n(a,q(m(a))))})}}k()}function I(b,d,a,c,e){a=a||function(){};var f,g=Array.isArray(b),k={},h=0,l=function(){function b(c,e){var d=!1;return function(b){if(d)throw Error("Callback was already called.");d=!0;b||(k[c+""]=e);++h>=f&&a(g?t(k):k)}}function c(b,d){var e=!1;return function(c){if(e)throw Error("Callback was already called."); | ||
e=!0;c&&(k[b+""]=d);++h>=f&&a(g?t(k):k)}}return e?b:c}(),m=c?d.bind(c):d;d=function(a,b){m(a,l(b,a))};if(g){f=b.length;if(!f)return a([]);s(b,d)}else{f=Object.keys(b).length;if(!f)return a({});v(b,d)}}function J(b,d,a,c,e){a=a||function(){};var f,g,k=Array.isArray(b),h={},l=0,m=function(){function b(c,e){var d=!1;return function(b){if(d)throw Error("Callback was already called.");d=!0;b||(h[c+""]=e);if(++l>=f)return a(k?t(h):h);g()}}function c(b,d){var e=!1;return function(c){if(e)throw Error("Callback was already called."); | ||
e=!0;c&&(h[b+""]=d);if(++l>=f)return a(k?t(h):h);g()}}return e?b:c}(),n=c?d.bind(c):d;if(k){f=b.length;if(!f)return a([]);g=function(){var a=b[l];n(a,m(l,a))}}else{var p=Object.keys(b);f=p.length;if(!f)return a({});g=function(){var a=p[l],c=b[a];n(c,m(a,c))}}g()}function K(b,d,a,c,e,f){c=c||function(){};var g,k,h=Array.isArray(b),l={},m=0,n=0,p=function(){function a(b,e){return function(a){a||(l[b+""]=e);if(++m>=g)return c(h?t(l):l);m>=n+d&&(n=m,k())}}function b(a,e){return function(b){b&&(l[a+""]= | ||
e);if(++m>=g)return c(h?t(l):l);m>=n+d&&(n=m,k())}}return f?a:b}(),A=e?a.bind(e):a;if(h){g=b.length;if(!g)return c([]);k=function(){r(d,function(a){if(!(n+a>=g)){a=n+a;var c=b[a];A(c,q(p(a,c)))}})}}else{var Y=Object.keys(b);g=Y.length;if(!g)return c({});k=function(){r(d,function(a){if(!(n+a>=g)){a=Y[n+a];var c=b[a];A(c,q(p(a,c)))}})}}k()}function O(b,d,a,c,e){function f(a,b){if(h)throw Error("Callback was already called.");h=!0;if(a)return c(a);if(++l>=g)return c(null,b);k(b)}c=c||function(){};var g, | ||
k,h,l=0,m=e?a.bind(e):a;if(Array.isArray(b)){g=b.length;if(!g)return c(null,d);k=function(a){h=!1;m(a,b[l],f)}}else{var n=Object.keys(b);g=n.length;if(!g)return c(null,d);k=function(a){h=!1;m(a,b[n[l]],f)}}k(d)}function ca(b,d,a,c){function e(b,c){b?(a(b,g?w(k):z(k)),a=function(){}):!1===c?(a(null,g?w(k):z(k)),a=function(){}):++h>=f&&(a(null,k),a=function(){})}a=a||function(){};var f,g=Array.isArray(b),k=g?[]:{},h=0,l=c?d.bind(c):d;d=function(a,b){l(k,a,b,q(e))};if(g){f=b.length;if(!f)return a(null, | ||
k);s(b,d)}else{c=Object.keys(b);f=c.length;if(!f)return a(null,k);v(b,d,c)}}function da(b,d,a,c){function e(b,c){if(k)throw Error("Callback was already called.");k=!0;if(b)return a(b,l);if(!1===c||++m>=f)return a(null,l);g()}a=a||function(){};var f,g,k,h=Array.isArray(b),l=h?[]:{},m=0,n=c?d.bind(c):d;if(h){f=b.length;if(!f)return a(null,l);g=function(){k=!1;n(l,b[m],m,e)}}else{var p=Object.keys(b);f=p.length;if(!f)return a(null,l);g=function(){k=!1;var a=p[m];n(l,b[a],a,e)}}g()}function ea(b,d,a, | ||
c,e){function f(a,b){a?(c(a,h?w(l):z(l)),c=function(){}):!1===b?(c(null,h?w(l):z(l)),c=function(){}):++m>=g?(c(null,l),c=function(){}):m>=n+d&&(n=m,k())}c=c||function(){};var g,k,h=Array.isArray(b),l=h?[]:{},m=0,n=0,p=e?a.bind(e):a;if(h){g=b.length;if(!g)return c(null,l);k=function(){r(d,function(a){n+a>=g||(a=n+a,p(l,b[a],a,q(f)))})}}else{var A=Object.keys(b);g=A.length;if(!g)return c(null,l);k=function(){r(d,function(a){n+a>=g||(a=A[n+a],p(l,b[a],a,q(f)))})}}k()}function P(b){function d(a,b,d,h){b= | ||
c(b,h);X(a,b,e(d))}function a(a,b,d,h,l){d=c(d,l);Z(a,b,d,e(h))}function c(a,b){var c=b?a.bind(b):a;return function(a,b){c(a,function(c,d){if(c)return b(c);b(null,{item:a,criteria:d})})}}function e(a){return function(b,c){if(b)return a(b);var d=c.sort(function(a,b){return b.criteria<a.criteria});a(null,U(d,"item"))}}switch(b){case "series":return d;case "limit":return a;default:return function(a,b,d,h){b=c(b,h);W(a,b,e(d))}}}function Q(b){return function(d,a,c,e){(b?a.bind(b):a)(function(a,b){if(a)return e(a); | ||
d[c]=b;e()})}}function fa(b,d,a){var c=Q(a);ca(b,c,d,a)}function ga(b,d,a){var c=Q(a);da(b,c,d,a)}function R(b,d,a,c){var e=Q(c);ea(b,d,e,a,c)}function ha(){var b=arguments;return function(){var d=this,a=E(arguments),c=a.pop();O(b,a,function(a,b,c){a.push(function(a){var b=u(arguments,1);c(a,b)});b.apply(d,a)},function(a,b){b=Array.isArray(b)?b:[b];b.unshift(a);c.apply(d,b)})}}function ia(b){var d="series"===b?H:G;return function(a){var b=this,e=u(arguments,1),f=e.pop()||function(){};d(a,function(a, | ||
d){a.apply(b,e.concat(d))},f)}}function ja(b,d,a){function c(a,b,c){var d=Array.isArray(a)?a:[a];a&&d.length?(e.started=!0,c="function"==typeof c?c:null,s(d,function(a){e.tasks.push({task:a,priority:b,callback:c});e.tasks=e.tasks.sort(function(a,b){return b.priority<a.priority});"function"==typeof e.saturated&&e.length()>=e.concurrency&&e.saturated();x(e.process)})):e.idle()&&"function"==typeof e.drain&&x(e.drain)}var e={tasks:[],concurrency:d||1,saturated:null,empty:null,drain:null,started:!1,paused:!1, | ||
push:function(a,b,d){c(a,b,d)},kill:function(){e.drain=null;e.tasks=[]},process:function(){function a(){f--;b.callback&&b.callback.apply(b,arguments);"function"==typeof e.drain&&e.idle()&&e.drain();e.process()}if(!(e.paused||f>=e.concurrency)&&e.length()){var b=e.tasks.shift();"function"!=typeof e.empty||e.length()||e.empty();f++;(e._thisArg?e._worker.bind(e._thisArg):e._worker)(b.task,q(a))}},length:function(){return e.tasks.length},running:function(){return f},idle:function(){return 0===e.length()+ | ||
f},pause:function(){e.paused=!0},resume:function(){!1!==e.paused&&(e.paused=!1,r(e.concurrency,function(){B.setImmediate(e.process)}))},_worker:b,_thisArg:a},f=0;return e}function ka(b,d,a,c){function e(c){var d=!1;return function(m,n){if(d)throw Error("Callback was already called.");d=!0;f[c]=n;if(m)return a(m);if(++g>=b)return a(null,f);k(g,e(g))}}a=a||function(){};var f=[];if(1>b)return a(null,f);var g=0,k=c?d.bind(c):d;k(g,e(g))}function S(b){function d(a){var c=u(arguments,1);console&&(a?console.error&& | ||
console.error(a):console[b]&&s(c,console[b]))}return function(a){var b=u(arguments,1);b.push(d);a.apply(null,b)}}function y(b,d){this._emitter=b||ga;this._limit=d||4;this._events={}}var F=this,na=F&&F.async,C={"function":!0,object:!0},D,x;(function(){C[typeof process]&&process.nextTick?(D=process.nextTick,x=C[typeof setImmediate]?function(b){setImmediate(b)}:D):x=D=C[typeof setImmediate]?function(b){setImmediate(b)}:function(b){setTimeout(b,0)}})();var B={VERSION:require("../package.json").version, | ||
each:G,eachSeries:H,eachLimit:V,forEach:G,forEachSeries:H,forEachLimit:V,map:W,mapSeries:X,mapLimit:Z,filter:$,filterSeries:aa,filterLimit:ba,select:$,selectSeries:aa,selectLimit:ba,reject:function(b,d,a,c){I(b,d,a,c,!0)},rejectSeries:function(b,d,a,c){J(b,d,a,c,!0)},rejectLimit:function(b,d,a,c,e){K(b,d,a,c,e,!0)},detect:L,detectSeries:M,detectLimit:N,pick:I,pickSeries:J,pickLimit:K,reduce:O,reduceRight:function(b,d,a,c,e){function f(a,b){if(h)throw Error("Callback was already called.");h=!0;if(a)return c(a); | ||
if(++l>=g)return c(null,b);k(b)}c=c||function(){};var g,k,h,l=0,m=e?a.bind(e):a;if(Array.isArray(b)){g=b.length;if(!g)return c(null,d);k=function(a){h=!1;m(a,b[g-l-1],f)}}else{var n=Object.keys(b);g=n.length;if(!g)return c(null,d);k=function(a){h=!1;m(a,b[n[g-l-1]],f)}}k(d)},transform:ca,transformSeries:da,transformLimit:ea,sortBy:P(),sortBySeries:P("series"),sortByLimit:P("limit"),some:function(b,d,a,c){L(b,d,function(b){a(!!b)},c)},someSeries:function(b,d,a,c){M(b,d,function(b){a(!!b)},c)},someLimit:function(b, | ||
d,a,c,e){N(b,d,a,function(a){c(!!a)},e)},every:function(b,d,a,c){L(b,d,function(b){a=a||function(){};a(!b)},c,!0)},everySeries:function(b,d,a,c){M(b,d,function(b){a=a||function(){};a(!b)},c,!0)},everyLimit:function(b,d,a,c,e){N(b,d,a,function(a){c=c||function(){};c(!a)},e,!0)},concat:function(b,d,a,c){function e(b,c){c&&Array.prototype.push.apply(g,Array.isArray(c)?c:[c]);b?(a(b,w(g)),a=function(){}):++k>=f&&(a(null,g),a=function(){})}a=a||function(){};var f,g=[],k=0,h=c?d.bind(c):d;d=function(a){h(a, | ||
q(e))};if(Array.isArray(b)){f=b.length;if(!f)return a(null,g);s(b,d)}else{c=Object.keys(b);f=c.length;if(!f)return a(null,g);v(b,d,c)}},concatSeries:function(b,d,a,c){function e(b,c){if(k)throw Error("Callback was already called.");k=!0;c&&Array.prototype.push.apply(h,Array.isArray(c)?c:[c]);if(b)return a(b,h);if(++l>=f)return a(null,h);g()}a=a||function(){};var f,g,k,h=[],l=0,m=c?d.bind(c):d;if(Array.isArray(b)){f=b.length;if(!f)return a(null,h);g=function(){k=!1;m(b[l],e)}}else{var n=Object.keys(b); | ||
f=n.length;if(!f)return a(null,h);g=function(){k=!1;m(b[n[l]],e)}}g()},concatLimit:function(b,d,a,c,e){function f(a,b){b&&Array.prototype.push.apply(h,Array.isArray(b)?b:[b]);a?(c(a,h),c=function(){}):++l>=g?(c(null,h),c=function(){}):l>=m+d&&(m=l,k())}c=c||function(){};var g,k,h=[],l=0,m=0,n=e?a.bind(e):a;if(Array.isArray(b)){g=b.length;if(!g)return c(null,h);k=function(){r(d,function(a){m+a>=g||n(b[m+a],q(f))})}}else{var p=Object.keys(b);g=p.length;if(!g)return c(null,h);k=function(){r(d,function(a){m+ | ||
a>=g||n(b[p[m+a]],q(f))})}}k()},multiEach:function(b,d,a){function c(c){c?(a(c),a=function(){}):k>=g&&l&&(a(null,b),a=function(){})}function e(a){var b=f[a];return function(d,f){if(d)return c(d);var q=e(a+1);b&&"object"==typeof f&&ma(f,function(a,d){if(a===h)return l=!0,c();g++;b(a,d,q)});if(a)return k++,c()}}a=a||function(){};var f=Array.isArray(d)?d:t(d);if(!d||!f.length)return a(null,b);var g=0,k=0,h={},l=!1;d=Array.isArray(b)?w(b):t(b);d.push(h);e(0)(null,d)},parallel:fa,series:ga,parallelLimit:R, | ||
waterfall:function(b,d,a){var c=function(){return a?function(b,c,d){function k(a){if(a)return d(a);var c=u(arguments,1);b.args=c;d(null,b)}var h=b.args||[];switch(h.length){case 0:return c.call(a,k);case 1:return c.call(a,h[0],k);case 2:return c.call(a,h[0],h[1],k);case 3:return c.call(a,h[0],h[1],h[2],k);case 4:return c.call(a,h[0],h[1],h[2],h[3],k);case 5:return c.call(a,h[0],h[1],h[2],h[3],h[4],k);default:return h.push(k),c.apply(a,h)}}:function(a,b,c){function d(b){if(b)return c(b);var f=u(arguments, | ||
1);a.args=f;c(null,a)}var h=a.args||[];switch(h.length){case 0:return b(d);case 1:return b(h[0],d);case 2:return b(h[0],h[1],d);case 3:return b(h[0],h[1],h[2],d);case 4:return b(h[0],h[1],h[2],h[3],d);case 5:return b(h[0],h[1],h[2],h[3],h[4],d);default:return h.push(d),b.apply(null,h)}}}();O(b,{},c,function(b,c){if(b)return d(b);var g=c.args||[];g.unshift(b);d.apply(a,g)})},whilst:function(b,d,a,c){function e(){b()?f(function(b){if(b)return a(b);e()}):a()}a=a||function(){};var f=c?d.bind(c):d;e()}, | ||
doWhilst:function(b,d,a,c){function e(){f(function(b){if(b)return a(b);var f=u(arguments,1);d.apply(c,f)?e():a()})}a=a||function(){};var f=c?b.bind(c):b;e()},until:function(b,d,a,c){function e(){b()?a():f(function(b){if(b)return a(b);e()})}a=a||function(){};var f=c?d.bind(c):d;e()},doUntil:function(b,d,a,c){function e(){f(function(b){if(b)return a(b);var f=u(arguments,1);d.apply(c,f)?a():e()})}a=a||function(){};var f=c?b.bind(c):b;e()},forever:function(b,d,a){function c(){e(function(a){if(a)return d(a); | ||
c()})}d=d||function(){};var e=a?b.bind(a):b;c()},compose:function(){return ha.apply(null,la(arguments))},seq:ha,applyEach:ia(),applyEachSeries:ia("series"),queue:function(b,d,a){function c(a,b,c){var d=Array.isArray(a)?a:[a];a&&d.length?(e.started=!0,b="function"==typeof b?b:null,s(d,function(a){a={task:a,callback:b};c?e.tasks.unshift(a):e.tasks.push(a);"function"==typeof e.saturated&&e.length()>=e.concurrency&&e.saturated();x(e.process)})):e.idle()&&"function"==typeof e.drain&&x(e.drain)}var e=ja(b, | ||
d,a);e.unshift=function(a,b){c(a,b,!0)};e.push=function(a,b){c(a,b)};return e},priorityQueue:ja,cargo:function(b,d){var a={tasks:[],payload:d,saturated:null,empty:null,drain:null,drained:!0,push:function(b,c){b=Array.isArray(b)?b:[b];c="function"==typeof c?c:null;s(b,function(b){a.tasks.push({data:b,callback:c});a.drained=!1;"function"==typeof a.saturated&&a.length()===a.payload&&a.saturated()});x(a.process)},process:function(){if(!c)if(a.length()){var e="number"==typeof a.payload?a.tasks.splice(0, | ||
d):a.tasks,f=U(e,"data");a.length()||"function"!=typeof a.empty||a.empty();c=!0;b(f,function(){c=!1;var b=arguments;s(e,function(a){a.callback&&a.callback.apply(null,b)});a.process()})}else"function"!=typeof a.drain||a.drained||a.drain(),a.drained=!0},length:function(){return a.tasks.length},running:function(){return c}},c=!1;return a},auto:function(b,d){function a(a){g.unshift(a)}function c(){f--;s(g.slice(0),function(a){a()})}d=d?q(d):function(){};var e=Object.keys(b),f=e.length;if(!f)return d(); | ||
var g=[],k={};a(function(){f||d(null,k)});v(b,function(b,e){function f(a){var b=u(arguments,1);1>=b.length&&(b=b[0]);if(a){var g=z(k);g[e]=b;return d(a,g)}k[e]=b;x(c)}function n(){return!k.hasOwnProperty(e)&&T(r,function(a){return k.hasOwnProperty(a)})}function p(){if(n()){var a;a:{a=-1;for(var b=g.length;++a<b;)if(g[a]===p)break a;a=-1}0<=a&&g.splice(a,1);s(f,k)}}b=Array.isArray(b)?b:[b];var q=b.length,r=b.slice(0,q-1),s=b[q-1];if(n())return s(f,k);a(p)},e)},retry:function(b,d,a){function c(c,f){a= | ||
c||a||function(){};var g,k;ka(b,function(a,c){d(function(d,e){g=d;k=e;if(!d)return c(!0);c(d&&a===b-1)},f)},function(){a(g,k)})}"function"==typeof b&&(a=d,d=b,b=5);b=parseInt(b,10)||5;return"function"==typeof a?c():c},iterator:function(b){function d(e){var f=function(){a&&b[c[e]||e].apply(null,arguments);return f.next()};f.next=function(){return e<a-1?d(e+1):null};return f}var a=0,c=[];Array.isArray(b)?a=b.length:(c=Object.keys(b),a=c.length);return d(0)},apply:function(b){var d=u(arguments,1);return function(){b.apply(null, | ||
Array.prototype.concat.apply(d,E(arguments)))}},nextTick:D,setImmediate:x,times:function(b,d,a,c){function e(c){return function(d,e){if(!g){f[c]=e;if(d)return g=!0,a(d);++k>=b&&(g=!0,a(null,f))}}}a=a||function(){};var f=[];if(1>b)return a(null,f);var g=!1,k=0,h=c?d.bind(c):d;r(b,function(a){h(a,q(e(a)))})},timesSeries:ka,timesLimit:function(b,d,a,c,e){function f(a){return function(e,f){if(!k){g[a]=f;if(e)return k=!0,c(e);if(++h>=b)return k=!0,c(null,g);h>=l+d&&(l=h,n())}}}c=c||function(){};var g= | ||
[];if(1>b)return c(null,g);var k=!1,h=0,l=0,m=e?a.bind(e):a,n=function(){r(d,function(a){l+a>=b||(a=l+a,m(a,q(f(a))))})};n()},memoize:function(b,d,a){d=d||function(a){return a};var c={},e={},f=function(){function f(){var b=E(arguments);c[l]=b;var d=e[l];delete e[l];for(var g=-1,h=d.length;++g<h;)d[g].apply(a,b)}var k=E(arguments),h=k.pop(),l=d.apply(null,k);if(c.hasOwnProperty(l))D(function(){h.apply(a,c[l])});else{if(e.hasOwnProperty(l))return e[l].push(h);e[l]=[h];k.push(f);b.apply(a,k)}};f.memo= | ||
c;f.unmemoized=b;return f},unmemoize:function(b){return function(){return(b.unmemoized||b).apply(null,arguments)}},log:S("log"),dir:S("dir"),createLogger:S,noConflict:function(){F.async=na;return B},eventEmitter:function(b){b=b||{};var d=b.limit;return b.parallel&&!d?new y(fa):b.parallel||b.parallelLimit?new y(R,d):new y(b.emitter)},EventEmitter:y};C[typeof module]&&module&&module.exports?module.exports=B:C[typeof define]&&define&&define.amd?define([],function(){return B}):F.async=B;y.prototype.on= | ||
function d(a,c){var e=this;"object"==typeof a?v(a,function(a,c){d.call(e,c,a)}):(e._events[a]=e._events[a]||[],Array.isArray(c)?Array.prototype.push.apply(e._events[a],c):e._events[a].push(c));return e};y.prototype.once=function a(c,e){var f=this;"object"==typeof c?v(c,function(c,e){a.call(f,e,c)}):(Array.isArray(e)?T(e,function(a){a._once=!0}):e._once=!0,f.on(c,e));return f};y.prototype.emit=function(a,c,e){function f(a,e){for(var f=g.length;--f;)g[f]._once&&g.splice(f,1);c(a,e)}c=c||function(){}; | ||
var g=this._events[a]||[];if(!g.length)return c();a=this._emitter;a=e?a.bind(e):a;a===R?a(g,this._limit,f):a(g,f);return this}}).call(this); | ||
a[c];d(b[f],f,b)}return b}function ma(b,d){return Array.isArray(b)?s(b,d):v(b,d)}function q(b,d){for(var a=-1;++a<b;)d(a)}function T(b,d){for(var a=b.length,c=-1;++c<a;)if(!d(b[c]))return!1;return!0}function w(b){for(var d=b.length,a=-1,c=Array(d);++a<d;)c[a]=b[a];return c}function z(b){for(var d=Object.keys(b),a=d.length,c=-1,e={};++c<a;){var f=d[c];e[f]=b[f]}return e}function U(b,d){for(var a=-1,c=b.length,e=Array(c);++a<c;)e[a]=(b[a]||{})[d];return e}function r(b){var d=!1;return function(a,c){if(d){if(a)return b(a, | ||
c);throw Error("Callback was already called.");}d=!0;b(a,c)}}function G(b,d,a,c){function e(b,c){b?(a(b),a=function(){}):!1===c?(a(),a=function(){}):++g>=f&&(a(),a=function(){})}a=a||function(){};var f,g=0,h=c?d.bind(c):d;d=function(a){h(a,r(e))};if(Array.isArray(b)){f=b.length;if(!f)return a();s(b,d)}else{c=Object.keys(b);f=c.length;if(!f)return a();v(b,d,c)}}function H(b,d,a,c){function e(b,c){if(h)throw Error("Callback was already called.");h=!0;if(b)return a(b);if(++k>=f||!1===c)return a();g()} | ||
a=a||function(){};var f,g,h,k=0,l=c?d.bind(c):d;if(Array.isArray(b)){f=b.length;if(!f)return a();g=function(){h=!1;l(b[k],e)}}else{var m=Object.keys(b);f=m.length;if(!f)return a();g=function(){h=!1;l(b[m[k]],e)}}g()}function V(b,d,a,c,e){function f(a,b){a?(c(a),c=function(){}):++k>=g?(c(),c=function(){}):!1===b?(c(),c=function(){}):k>=l+d&&(l=k,h())}c=c||function(){};var g,h,k=0,l=0,m=e?a.bind(e):a;if(Array.isArray(b)){g=b.length;if(!g)return c();h=function(){q(d,function(a){a=l+a;a>=g||m(b[a],r(f))})}}else{var n= | ||
Object.keys(b);g=n.length;if(!g)return c();h=function(){q(d,function(a){a=l+a;a>=g||m(b[n[a]],r(f))})}}h()}function W(b,d,a,c){function e(b){var c=!1;return function(d,e){if(c)throw Error("Callback was already called.");c=!0;g[b]=e;d?(a(d,w(g)),a=function(){}):++k>=f&&(a(null,g),a=function(){})}}a=a||function(){};var f,g,h=0,k=0,l=c?d.bind(c):d;d=function(a){l(a,e(h++))};if(Array.isArray(b)){f=b.length;g=Array(f);if(!f)return a(null,g);s(b,d)}else{c=Object.keys(b);f=c.length;g=Array(f);if(!f)return a(null, | ||
g);v(b,d,c)}}function X(b,d,a,c){function e(b){var c=!1;return function(d,e){if(c)throw Error("Callback was already called.");c=!0;g[b]=e;d?(a(d,w(g)),a=function(){}):++k>=f?(a(null,g),a=function(){}):h()}}a=a||function(){};var f,g,h,k=0,l=c?d.bind(c):d;if(Array.isArray(b)){f=b.length;g=Array(f);if(!f)return a(null,g);h=function(){l(b[k],e(k))}}else{var m=Object.keys(b);f=m.length;g=Array(f);if(!f)return a(null,g);h=function(){l(b[m[k]],e(k))}}h()}function Z(b,d,a,c,e){function f(a){var b=!1;return function(e, | ||
f){if(b)throw Error("Callback was already called.");b=!0;h[a]=f;e?(c(e,w(h)),c=function(){}):++l>=g?(c(null,h),c=function(){}):l>=m+d&&(m=l,k())}}c=c||function(){};var g,h,k,l=0,m=0,n=e?a.bind(e):a;if(Array.isArray(b)){g=b.length;h=Array(g);if(!g)return c(null,h);k=function(){q(d,function(a){a=m+a;a>=g||n(b[a],f(a))})}}else{var p=Object.keys(b);g=p.length;h=Array(g);if(!g)return c(null,h);k=function(){q(d,function(a){a=m+a;a>=g||n(b[p[a]],f(a))})}}k()}function $(b,d,a,c){I(b,d,function(c){a=a||function(){}; | ||
a(Array.isArray(b)?c:t(c))},c)}function aa(b,d,a,c){J(b,d,function(c){a=a||function(){};a(Array.isArray(b)?c:t(c))},c)}function ba(b,d,a,c,e){K(b,d,a,function(a){c=c||function(){};c(Array.isArray(b)?a:t(a))},e)}function L(b,d,a,c,e){a=a||function(){};var f,g=0,h=function(){function b(c){return function(b){b?++g>=f&&(a(),a=function(){}):(a(c),a=function(){})}}function c(b){return function(c){c?(a(b),a=function(){}):++g>=f&&(a(),a=function(){})}}return e?b:c}(),k=c?d.bind(c):d;d=function(a){k(a,h(a))}; | ||
if(Array.isArray(b)){f=b.length;if(!f)return a();s(b,d)}else{f=Object.keys(b).length;if(!f)return a();v(b,d)}}function M(b,d,a,c,e){a=a||function(){};var f,g,h,k=0,l=function(){function b(c){return function(b){if(h)throw Error("Callback was already called.");h=!0;if(!b)return a(c);if(++k>=f)return a();g()}}function c(b){return function(c){if(h)throw Error("Callback was already called.");h=!0;if(c)return a(b);if(++k>=f)return a();g()}}return e?b:c}(),m=c?d.bind(c):d;if(Array.isArray(b)){f=b.length; | ||
if(!f)return a();g=function(){h=!1;var a=b[k];m(a,l(a))}}else{var n=Object.keys(b);f=n.length;if(!f)return a();g=function(){h=!1;var a=b[n[k]];m(a,l(a))}}g()}function N(b,d,a,c,e,f){c=c||function(){};var g,h,k=0,l=0,m=function(){function a(b){return function(a){a?++k>=g?(c(),c=function(){}):k>=l+d&&(l=k,h()):(c(b),c=function(){})}}function b(a){return function(b){b?(c(a),c=function(){}):++k>=g?(c(),c=function(){}):k>=l+d&&(l=k,h())}}return f?a:b}(),n=e?a.bind(e):a;if(Array.isArray(b)){g=b.length; | ||
if(!g)return c();h=function(){q(d,function(a){a=l+a;a>=g||(a=b[a],n(a,r(m(a))))})}}else{var p=Object.keys(b);g=p.length;if(!g)return c();h=function(){q(d,function(a){a=l+a;a>=g||(a=b[p[a]],n(a,r(m(a))))})}}h()}function I(b,d,a,c,e){a=a||function(){};var f,g=Array.isArray(b),h={},k=0,l=function(){function b(c,d){var e=!1;return function(b){if(e)throw Error("Callback was already called.");e=!0;b||(h[c+""]=d);++k>=f&&a(g?t(h):h)}}function c(b,d){var e=!1;return function(c){if(e)throw Error("Callback was already called."); | ||
e=!0;c&&(h[b+""]=d);++k>=f&&a(g?t(h):h)}}return e?b:c}(),m=c?d.bind(c):d;d=function(a,b){m(a,l(b,a))};if(g){f=b.length;if(!f)return a([]);s(b,d)}else{f=Object.keys(b).length;if(!f)return a({});v(b,d)}}function J(b,d,a,c,e){a=a||function(){};var f,g,h=Array.isArray(b),k={},l=0,m=function(){function b(c,d){var e=!1;return function(b){if(e)throw Error("Callback was already called.");e=!0;b||(k[c+""]=d);if(++l>=f)return a(h?t(k):k);g()}}function c(b,d){var e=!1;return function(c){if(e)throw Error("Callback was already called."); | ||
e=!0;c&&(k[b+""]=d);if(++l>=f)return a(h?t(k):k);g()}}return e?b:c}(),n=c?d.bind(c):d;if(h){f=b.length;if(!f)return a([]);g=function(){var a=b[l];n(a,m(l,a))}}else{var p=Object.keys(b);f=p.length;if(!f)return a({});g=function(){var a=p[l],c=b[a];n(c,m(a,c))}}g()}function K(b,d,a,c,e,f){c=c||function(){};var g,h,k=Array.isArray(b),l={},m=0,n=0,p=function(){function a(b,e){var f=!1;return function(a){if(f)throw Error("Callback was already called.");f=!0;a||(l[b+""]=e);if(++m>=g)return c(k?t(l):l);m>= | ||
n+d&&(n=m,h())}}function b(a,e){var f=!1;return function(b){if(f)throw Error("Callback was already called.");f=!0;b&&(l[a+""]=e);if(++m>=g)return c(k?t(l):l);m>=n+d&&(n=m,h())}}return f?a:b}(),A=e?a.bind(e):a;if(k){g=b.length;if(!g)return c([]);h=function(){q(d,function(a){a=n+a;if(!(a>=g)){var c=b[a];A(c,p(a,c))}})}}else{var Y=Object.keys(b);g=Y.length;if(!g)return c({});h=function(){q(d,function(a){a=n+a;if(!(a>=g)){a=Y[a];var c=b[a];A(c,p(a,c))}})}}h()}function O(b,d,a,c,e){function f(a,b){if(k)throw Error("Callback was already called."); | ||
k=!0;if(a)return c(a);if(++l>=g)return c(null,b);h(b)}c=c||function(){};var g,h,k,l=0,m=e?a.bind(e):a;if(Array.isArray(b)){g=b.length;if(!g)return c(null,d);h=function(a){k=!1;m(a,b[l],f)}}else{var n=Object.keys(b);g=n.length;if(!g)return c(null,d);h=function(a){k=!1;m(a,b[n[l]],f)}}h(d)}function ca(b,d,a,c){function e(b,c){b?(a(b,g?w(h):z(h)),a=function(){}):!1===c?(a(null,g?w(h):z(h)),a=function(){}):++k>=f&&(a(null,h),a=function(){})}a=a||function(){};var f,g=Array.isArray(b),h=g?[]:{},k=0,l=c? | ||
d.bind(c):d;d=function(a,b){l(h,a,b,r(e))};if(g){f=b.length;if(!f)return a(null,h);s(b,d)}else{c=Object.keys(b);f=c.length;if(!f)return a(null,h);v(b,d,c)}}function da(b,d,a,c){function e(b,c){if(h)throw Error("Callback was already called.");h=!0;if(b)return a(b,l);if(!1===c||++m>=f)return a(null,l);g()}a=a||function(){};var f,g,h,k=Array.isArray(b),l=k?[]:{},m=0,n=c?d.bind(c):d;if(k){f=b.length;if(!f)return a(null,l);g=function(){h=!1;n(l,b[m],m,e)}}else{var p=Object.keys(b);f=p.length;if(!f)return a(null, | ||
l);g=function(){h=!1;var a=p[m];n(l,b[a],a,e)}}g()}function ea(b,d,a,c,e){function f(a,b){a?(c(a,k?w(l):z(l)),c=function(){}):!1===b?(c(null,k?w(l):z(l)),c=function(){}):++m>=g?(c(null,l),c=function(){}):m>=n+d&&(n=m,h())}c=c||function(){};var g,h,k=Array.isArray(b),l=k?[]:{},m=0,n=0,p=e?a.bind(e):a;if(k){g=b.length;if(!g)return c(null,l);h=function(){q(d,function(a){a=n+a;a>=g||p(l,b[a],a,r(f))})}}else{var A=Object.keys(b);g=A.length;if(!g)return c(null,l);h=function(){q(d,function(a){a=n+a;a>=g|| | ||
(a=A[a],p(l,b[a],a,r(f)))})}}h()}function P(b){function d(a,b,d,k){b=c(b,k);X(a,b,e(d))}function a(a,b,d,k,l){d=c(d,l);Z(a,b,d,e(k))}function c(a,b){var c=b?a.bind(b):a;return function(a,b){c(a,function(c,d){if(c)return b(c);b(null,{item:a,criteria:d})})}}function e(a){return function(b,c){if(b)return a(b);var d=c.sort(function(a,b){return b.criteria<a.criteria});a(null,U(d,"item"))}}switch(b){case "series":return d;case "limit":return a;default:return function(a,b,d,k){b=c(b,k);W(a,b,e(d))}}}function Q(b){return function(d, | ||
a,c,e){(b?a.bind(b):a)(function(a,b){if(a)return e(a);d[c]=b;e()})}}function fa(b,d,a){var c=Q(a);ca(b,c,d,a)}function ga(b,d,a){var c=Q(a);da(b,c,d,a)}function R(b,d,a,c){var e=Q(c);ea(b,d,e,a,c)}function ha(){var b=arguments;return function(){var d=this,a=E(arguments),c=a.pop();O(b,a,function(a,b,c){a.push(function(a){var b=u(arguments,1);c(a,b)});b.apply(d,a)},function(a,b){b=Array.isArray(b)?b:[b];b.unshift(a);c.apply(d,b)})}}function ia(b){var d="series"===b?H:G;return function(a){var b=this, | ||
e=u(arguments,1),f=e.pop()||function(){};d(a,function(a,d){a.apply(b,e.concat(d))},f)}}function ja(b,d,a){function c(a,b,c){var d=Array.isArray(a)?a:[a];a&&d.length?(e.started=!0,c="function"==typeof c?c:null,s(d,function(a){e.tasks.push({task:a,priority:b,callback:c});e.tasks=e.tasks.sort(function(a,b){return b.priority<a.priority});"function"==typeof e.saturated&&e.length()>=e.concurrency&&e.saturated();x(e.process)})):e.idle()&&"function"==typeof e.drain&&x(e.drain)}var e={tasks:[],concurrency:d|| | ||
1,saturated:null,empty:null,drain:null,started:!1,paused:!1,push:function(a,b,d){c(a,b,d)},kill:function(){e.drain=null;e.tasks=[]},process:function(){function a(){f--;b.callback&&b.callback.apply(b,arguments);"function"==typeof e.drain&&e.idle()&&e.drain();e.process()}if(!(e.paused||f>=e.concurrency)&&e.length()){var b=e.tasks.shift();"function"!=typeof e.empty||e.length()||e.empty();f++;(e._thisArg?e._worker.bind(e._thisArg):e._worker)(b.task,r(a))}},length:function(){return e.tasks.length},running:function(){return f}, | ||
idle:function(){return 0===e.length()+f},pause:function(){e.paused=!0},resume:function(){!1!==e.paused&&(e.paused=!1,q(e.concurrency,function(){B.setImmediate(e.process)}))},_worker:b,_thisArg:a},f=0;return e}function ka(b,d,a,c){function e(c){var d=!1;return function(m,n){if(d)throw Error("Callback was already called.");d=!0;f[c]=n;if(m)return a(m);if(++g>=b)return a(null,f);h(g,e(g))}}a=a||function(){};var f=[];if(1>b)return a(null,f);var g=0,h=c?d.bind(c):d;h(g,e(g))}function S(b){function d(a){var c= | ||
u(arguments,1);console&&(a?console.error&&console.error(a):console[b]&&s(c,console[b]))}return function(a){var b=u(arguments,1);b.push(d);a.apply(null,b)}}function y(b,d){this._emitter=b||ga;this._limit=d||4;this._events={}}var F=this,na=F&&F.async,C={"function":!0,object:!0},D,x;(function(){C[typeof process]&&process.nextTick?(D=process.nextTick,x=C[typeof setImmediate]?function(b){setImmediate(b)}:D):x=D=C[typeof setImmediate]?function(b){setImmediate(b)}:function(b){setTimeout(b,0)}})();var B= | ||
{VERSION:require("../package.json").version,each:G,eachSeries:H,eachLimit:V,forEach:G,forEachSeries:H,forEachLimit:V,map:W,mapSeries:X,mapLimit:Z,filter:$,filterSeries:aa,filterLimit:ba,select:$,selectSeries:aa,selectLimit:ba,reject:function(b,d,a,c){I(b,d,a,c,!0)},rejectSeries:function(b,d,a,c){J(b,d,a,c,!0)},rejectLimit:function(b,d,a,c,e){K(b,d,a,c,e,!0)},detect:L,detectSeries:M,detectLimit:N,pick:I,pickSeries:J,pickLimit:K,reduce:O,reduceRight:function(b,d,a,c,e){function f(a,b){if(k)throw Error("Callback was already called."); | ||
k=!0;if(a)return c(a);if(++l>=g)return c(null,b);h(b)}c=c||function(){};var g,h,k,l=0,m=e?a.bind(e):a;if(Array.isArray(b)){g=b.length;if(!g)return c(null,d);h=function(a){k=!1;m(a,b[g-l-1],f)}}else{var n=Object.keys(b);g=n.length;if(!g)return c(null,d);h=function(a){k=!1;m(a,b[n[g-l-1]],f)}}h(d)},transform:ca,transformSeries:da,transformLimit:ea,sortBy:P(),sortBySeries:P("series"),sortByLimit:P("limit"),some:function(b,d,a,c){L(b,d,function(b){a=a||function(){};a(!!b)},c)},someSeries:function(b,d, | ||
a,c){M(b,d,function(b){a=a||function(){};a(!!b)},c)},someLimit:function(b,d,a,c,e){N(b,d,a,function(a){c=c||function(){};c(!!a)},e)},every:function(b,d,a,c){L(b,d,function(b){a=a||function(){};a(!b)},c,!0)},everySeries:function(b,d,a,c){M(b,d,function(b){a=a||function(){};a(!b)},c,!0)},everyLimit:function(b,d,a,c,e){N(b,d,a,function(a){c=c||function(){};c(!a)},e,!0)},concat:function(b,d,a,c){function e(b,c){c&&Array.prototype.push.apply(g,Array.isArray(c)?c:[c]);b?(a(b,w(g)),a=function(){}):++h>= | ||
f&&(a(null,g),a=function(){})}a=a||function(){};var f,g=[],h=0,k=c?d.bind(c):d;d=function(a){k(a,r(e))};if(Array.isArray(b)){f=b.length;if(!f)return a(null,g);s(b,d)}else{c=Object.keys(b);f=c.length;if(!f)return a(null,g);v(b,d,c)}},concatSeries:function(b,d,a,c){function e(b,c){if(h)throw Error("Callback was already called.");h=!0;c&&Array.prototype.push.apply(k,Array.isArray(c)?c:[c]);if(b)return a(b,k);if(++l>=f)return a(null,k);g()}a=a||function(){};var f,g,h,k=[],l=0,m=c?d.bind(c):d;if(Array.isArray(b)){f= | ||
b.length;if(!f)return a(null,k);g=function(){h=!1;m(b[l],e)}}else{var n=Object.keys(b);f=n.length;if(!f)return a(null,k);g=function(){h=!1;m(b[n[l]],e)}}g()},concatLimit:function(b,d,a,c,e){function f(a,b){b&&Array.prototype.push.apply(k,Array.isArray(b)?b:[b]);a?(c(a,k),c=function(){}):++l>=g?(c(null,k),c=function(){}):l>=m+d&&(m=l,h())}c=c||function(){};var g,h,k=[],l=0,m=0,n=e?a.bind(e):a;if(Array.isArray(b)){g=b.length;if(!g)return c(null,k);h=function(){q(d,function(a){a=m+a;a>=g||n(b[a],r(f))})}}else{var p= | ||
Object.keys(b);g=p.length;if(!g)return c(null,k);h=function(){q(d,function(a){a=m+a;a>=g||n(b[p[a]],r(f))})}}h()},multiEach:function(b,d,a){function c(c){c?(a(c),a=function(){}):h>=g&&l&&(a(null,b),a=function(){})}function e(a){var b=f[a];return function(d,f){if(d)return c(d);var q=e(a+1);b&&"object"==typeof f&&ma(f,function(a,d){if(a===k)return l=!0,c();g++;b(a,d,q)});if(a)return h++,c()}}a=a||function(){};var f=Array.isArray(d)?d:t(d);if(!d||!f.length)return a(null,b);var g=0,h=0,k={},l=!1;d=Array.isArray(b)? | ||
w(b):t(b);d.push(k);e(0)(null,d)},parallel:fa,series:ga,parallelLimit:R,waterfall:function(b,d,a){d=d||function(){};var c=function(){return a?function(b,c,d){function h(a){if(a)return d(a);var c=u(arguments,1);b.args=c;d(null,b)}var k=b.args||[];switch(k.length){case 0:return c.call(a,h);case 1:return c.call(a,k[0],h);case 2:return c.call(a,k[0],k[1],h);case 3:return c.call(a,k[0],k[1],k[2],h);case 4:return c.call(a,k[0],k[1],k[2],k[3],h);case 5:return c.call(a,k[0],k[1],k[2],k[3],k[4],h);default:return k.push(h), | ||
c.apply(a,k)}}:function(a,b,c){function d(b){if(b)return c(b);var f=u(arguments,1);a.args=f;c(null,a)}var k=a.args||[];switch(k.length){case 0:return b(d);case 1:return b(k[0],d);case 2:return b(k[0],k[1],d);case 3:return b(k[0],k[1],k[2],d);case 4:return b(k[0],k[1],k[2],k[3],d);case 5:return b(k[0],k[1],k[2],k[3],k[4],d);default:return k.push(d),b.apply(null,k)}}}();O(b,{},c,function(b,c){if(b)return d(b);var g=c.args||[];g.unshift(b);d.apply(a,g)})},whilst:function(b,d,a,c){function e(){b()?f(function(b){if(b)return a(b); | ||
e()}):a()}a=a||function(){};var f=c?d.bind(c):d;e()},doWhilst:function(b,d,a,c){function e(){f(function(b){if(b)return a(b);var f=u(arguments,1);d.apply(c,f)?e():a()})}a=a||function(){};var f=c?b.bind(c):b;e()},until:function(b,d,a,c){function e(){b()?a():f(function(b){if(b)return a(b);e()})}a=a||function(){};var f=c?d.bind(c):d;e()},doUntil:function(b,d,a,c){function e(){f(function(b){if(b)return a(b);var f=u(arguments,1);d.apply(c,f)?a():e()})}a=a||function(){};var f=c?b.bind(c):b;e()},forever:function(b, | ||
d,a){function c(){e(function(a){if(a)return d(a);c()})}d=d||function(){};var e=a?b.bind(a):b;c()},compose:function(){return ha.apply(null,la(arguments))},seq:ha,applyEach:ia(),applyEachSeries:ia("series"),queue:function(b,d,a){function c(a,b,c){var d=Array.isArray(a)?a:[a];a&&d.length?(e.started=!0,b="function"==typeof b?b:null,s(d,function(a){a={task:a,callback:b};c?e.tasks.unshift(a):e.tasks.push(a);"function"==typeof e.saturated&&e.length()>=e.concurrency&&e.saturated();x(e.process)})):e.idle()&& | ||
"function"==typeof e.drain&&x(e.drain)}var e=ja(b,d,a);e.unshift=function(a,b){c(a,b,!0)};e.push=function(a,b){c(a,b)};return e},priorityQueue:ja,cargo:function(b,d){var a={tasks:[],payload:d,saturated:null,empty:null,drain:null,drained:!0,push:function(b,c){b=Array.isArray(b)?b:[b];c="function"==typeof c?c:null;s(b,function(b){a.tasks.push({data:b,callback:c});a.drained=!1;"function"==typeof a.saturated&&a.length()===a.payload&&a.saturated()});x(a.process)},process:function(){if(!c)if(a.length()){var e= | ||
"number"==typeof a.payload?a.tasks.splice(0,d):a.tasks,f=U(e,"data");a.length()||"function"!=typeof a.empty||a.empty();c=!0;b(f,function(){c=!1;var b=arguments;s(e,function(a){a.callback&&a.callback.apply(null,b)});a.process()})}else"function"!=typeof a.drain||a.drained||a.drain(),a.drained=!0},length:function(){return a.tasks.length},running:function(){return c}},c=!1;return a},auto:function(b,d){function a(a){g.unshift(a)}function c(){f--;s(g.slice(0),function(a){a()})}d=d?r(d):function(){};var e= | ||
Object.keys(b),f=e.length;if(!f)return d();var g=[],h={};a(function(){f||d(null,h)});v(b,function(b,e){function f(a){var b=u(arguments,1);1>=b.length&&(b=b[0]);if(a){var g=z(h);g[e]=b;return d(a,g)}h[e]=b;x(c)}function n(){return!h.hasOwnProperty(e)&&T(s,function(a){return h.hasOwnProperty(a)})}function p(){if(n()){var a;a:{a=-1;for(var b=g.length;++a<b;)if(g[a]===p)break a;a=-1}0<=a&&g.splice(a,1);r(f,h)}}b=Array.isArray(b)?b:[b];var q=b.length,s=b.slice(0,q-1),r=b[q-1];if(n())return r(f,h);a(p)}, | ||
e)},retry:function(b,d,a){function c(c,f){a=c||a||function(){};var g,h;ka(b,function(a,c){d(function(d,e){g=d;h=e;if(!d)return c(!0);c(d&&a===b-1)},f)},function(){a(g,h)})}"function"==typeof b&&(a=d,d=b,b=5);b=parseInt(b,10)||5;return"function"==typeof a?c():c},iterator:function(b){function d(e){var f=function(){a&&b[c[e]||e].apply(null,arguments);return f.next()};f.next=function(){return e<a-1?d(e+1):null};return f}var a=0,c=[];Array.isArray(b)?a=b.length:(c=Object.keys(b),a=c.length);return d(0)}, | ||
apply:function(b){var d=u(arguments,1);return function(){b.apply(null,Array.prototype.concat.apply(d,E(arguments)))}},nextTick:D,setImmediate:x,times:function(b,d,a,c){function e(c){var d=!1;return function(e,h){if(d)throw Error("Callback was already called.");d=!0;f[c]=h;e?(a(e),a=function(){}):++g>=b&&(a(null,f),a=function(){})}}a=a||function(){};var f=[];if(1>b)return a(null,f);var g=0,h=c?d.bind(c):d;q(b,function(a){h(a,e(a))})},timesSeries:ka,timesLimit:function(b,d,a,c,e){function f(a){var e= | ||
!1;return function(f,l){if(e)throw Error("Callback was already called.");e=!0;g[a]=l;f?(c(f),c=function(){}):++h>=b?(c(null,g),c=function(){}):h>=k+d&&(k=h,m())}}c=c||function(){};var g=[];if(1>b)return c(null,g);var h=0,k=0,l=e?a.bind(e):a,m=function(){q(d,function(a){a=k+a;a>=b||l(a,f(a))})};m()},memoize:function(b,d,a){d=d||function(a){return a};var c={},e={},f=function(){function f(){var b=E(arguments);c[l]=b;var d=e[l];delete e[l];for(var g=-1,h=d.length;++g<h;)d[g].apply(a,b)}var h=E(arguments), | ||
k=h.pop(),l=d.apply(null,h);if(c.hasOwnProperty(l))D(function(){k.apply(a,c[l])});else{if(e.hasOwnProperty(l))return e[l].push(k);e[l]=[k];h.push(f);b.apply(a,h)}};f.memo=c;f.unmemoized=b;return f},unmemoize:function(b){return function(){return(b.unmemoized||b).apply(null,arguments)}},log:S("log"),dir:S("dir"),createLogger:S,noConflict:function(){F.async=na;return B},eventEmitter:function(b){b=b||{};var d=b.limit;return b.parallel&&!d?new y(fa):b.parallel||b.parallelLimit?new y(R,d):new y(b.emitter)}, | ||
EventEmitter:y};C[typeof module]&&module&&module.exports?module.exports=B:C[typeof define]&&define&&define.amd?define([],function(){return B}):F.async=B;y.prototype.on=function d(a,c){var e=this;"object"==typeof a?v(a,function(a,c){d.call(e,c,a)}):(e._events[a]=e._events[a]||[],Array.isArray(c)?Array.prototype.push.apply(e._events[a],c):e._events[a].push(c));return e};y.prototype.once=function a(c,e){var f=this;"object"==typeof c?v(c,function(c,e){a.call(f,e,c)}):(Array.isArray(e)?T(e,function(a){a._once= | ||
!0}):e._once=!0,f.on(c,e));return f};y.prototype.emit=function(a,c,e){function f(a,e){for(var f=g.length;--f;)g[f]._once&&g.splice(f,1);c(a,e)}c=c||function(){};var g=this._events[a]||[];if(!g.length)return c();a=this._emitter;a=e?a.bind(e):a;a===R?a(g,this._limit,f):a(g,f);return this}}).call(this); |
{ | ||
"name": "neo-async", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "Neo-Async is compatible with Async.js, it is faster and has more feature.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# Neo-Async | ||
[![Build Status](https://travis-ci.org/suguru03/neo-async.svg?branch=master)](https://travis-ci.org/suguru03/Neo-Async) | ||
[![codecov.io](https://codecov.io/github/suguru03/neo-async/coverage.svg?branch=master)](https://codecov.io/github/suguru03/neo-async?branch=master) | ||
![Neo-Async](https://raw.githubusercontent.com/wiki/suguru03/neo-async/images/neo_async.png) | ||
@@ -135,3 +136,3 @@ | ||
2. iterator(item, callback) (Function): The function called per iteration. | ||
3. callback(err) (Function): The function called at the end. | ||
3. callback(err, res) (Function): The function called at the end. | ||
4. thisArg (*): The this binding of iterator. | ||
@@ -164,3 +165,3 @@ | ||
2. iterator(item, callback) (Function): The function called per iteration. | ||
3. callback(err) (Function): The function called at the end. | ||
3. callback(err, res) (Function): The function called at the end. | ||
4. thisArg (*): The this binding of iterator. | ||
@@ -193,3 +194,3 @@ | ||
3. iterator(item, callback) (Function): The function called per iteration. | ||
4. callback(err) (Function): The function called at the end. | ||
4. callback(err, res) (Function): The function called at the end. | ||
5. thisArg (*): The this binding of iterator. | ||
@@ -206,3 +207,3 @@ | ||
}; | ||
async.concatSeries(collection, iterator, function(err, res) { | ||
async.concatLimit(collection, 2, iterator, function(err, res) { | ||
assert.deepEqual(res, [1, 3, 2]); | ||
@@ -216,2 +217,86 @@ assert.deepEqual(order, [1, 3, 2]); | ||
<a name='detect'/> | ||
### detect(collection, iterator, callback, thisArg) | ||
__Arguments__ | ||
1. collection (Array|Object): The collection to iterate over. | ||
2. iterator(item, callback) (Function): The function called per iteration. | ||
3. callback(res) (Function): The function called at the end. | ||
4. thisArg (*): The this binding of iterator. | ||
```js | ||
var order = []; | ||
var collection = [1, 3, 2]; | ||
var iterator = function(num, done) { | ||
setTimeout(function() { | ||
order.push(num); | ||
done(num === 3); | ||
}, num * 10); | ||
}; | ||
async.detect(collection, iterator, function(res) { | ||
assert.deepEqual(res, 3); | ||
assert.deepEqual(order, [1, 2, 3]); | ||
}); | ||
``` | ||
--- | ||
<a name='detectSeries'/> | ||
### detectSeries(collection, iterator, callback, thisArg) | ||
__Arguments__ | ||
1. collection (Array|Object): The collection to iterate over. | ||
2. iterator(item, callback) (Function): The function called per iteration. | ||
3. callback(res) (Function): The function called at the end. | ||
4. thisArg (*): The this binding of iterator. | ||
```js | ||
var order = []; | ||
var collection = [1, 3, 2]; | ||
var iterator = function(num, done) { | ||
setTimeout(function() { | ||
order.push(num); | ||
done(num === 3); | ||
}, num * 10); | ||
}; | ||
async.detectSeries(collection, iterator, function(res) { | ||
assert.deepEqual(res, 3); | ||
assert.deepEqual(order, [1, 3]); | ||
}); | ||
``` | ||
--- | ||
<a name='detectLimit'/> | ||
### detectLimit(collection, limit, iterator, callback, thisArg) | ||
__Arguments__ | ||
1. collection (Array|Object): The collection to iterate over. | ||
2. limit (Number): The maximum number of iterators to run at any time. | ||
3. iterator(item, callback) (Function): The function called per iteration. | ||
4. callback(res) (Function): The function called at the end. | ||
5. thisArg (*): The this binding of iterator. | ||
```js | ||
var order = []; | ||
var collection = [1, 3, 2]; | ||
var iterator = function(num, done) { | ||
setTimeout(function() { | ||
order.push(num); | ||
done(num === 3); | ||
}, num * 10); | ||
}; | ||
async.detectLimit(collection, 2, iterator, function(res) { | ||
assert.deepEqual(res, 3); | ||
assert.deepEqual(order, [1, 3]); | ||
}); | ||
``` | ||
--- | ||
<a name='each'/> | ||
@@ -432,3 +517,3 @@ ### each(collection, iterator, callback, thisArg) | ||
var times = 1000; | ||
var array = _.sample(_.times(count), count); | ||
var array = _.shuffle(_.times(count)); | ||
var tasks = _.map(array, function(n, i) { | ||
@@ -435,0 +520,0 @@ if (i === 0) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
100214
2402
603