Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

neo-async

Package Overview
Dependencies
Maintainers
1
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

neo-async - npm Package Compare versions

Comparing version 0.2.5 to 0.2.6

.travis.yml

2

index.js
'use strict';
module.exports = require('./lib/async.compact');
module.exports = require('./lib/async');
(function(){function s(b){return Object.keys(b)}function r(b){return Array.isArray(b)}function t(b){return"function"==typeof b}function z(b){for(var d=s(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 x(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 ga(b){for(var d=-1,a=b.length,c=Array(a);++d<a;)c[a-d-1]=b[d];return c}function w(b,d){for(var a=-1,c=b.length;++a<
c&&!1!==d(b[a],a,b););return b}function A(b,d,a){a=a||s(b);for(var c=-1,e=a.length;++c<e;){var f=a[c];if(!1===d(b[f],f,b))break}return b}function v(b,d){for(var a=-1;++a<b;)d(a)}function ha(b,d){for(var a=b.length,c=-1;++c<a;)if(!d(b[c]))return!1;return!0}function T(b){for(var d=b.length,a=-1,c=Array(d);++a<d;)c[a]=b[a];return c}function F(b){for(var d=s(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 p(b){var d=!1;return function(){if(d)throw Error("Callback was already called.");d=!0;b.apply(B,arguments)}}function G(b,d,a,c){function e(b,c){if(!k){if(b)return k=!0,a(b);if(!1===c)return k=!0,a();++h>=f&&(k=!0,a())}}a=a||function(){};var f=0,h=0,k=!1,g=c?d.bind(c):d;d=function(a){g(a,p(e))};if(r(b)){f=b.length;if(!f)return a();w(b,d)}else{c=s(b);f=c.length;if(!f)return a();A(b,d,c)}}function H(b,d,a,c){function e(b,c){if(!k){if(b)return k=!0,a(b);if(!1===c||++h>=f)return k=!0,a();l()}}
a=a||function(){};var f=0,h=0,k=!1,g=c?d.bind(c):d,l;if(r(b)){f=b.length;if(!f)return a();l=function(){g(b[h],p(e))}}else{var m=s(b),f=m.length;if(!f)return a();l=function(){g(b[m[h]],p(e))}}l()}function V(b,d,a,c,e){function f(a,b){if(!l){if(a)return l=!0,c(a);if(!1===b||++k>=h)return l=!0,c();k>=g+d&&(g=k,n())}}c=c||function(){};var h=0,k=0,g=0,l=!1,m=e?a.bind(e):a,n;if(r(b)){h=b.length;if(!h)return c();n=function(){v(d,function(a){g+a>=h||m(b[g+a],p(f))})}}else{var q=s(b),h=q.length;if(!h)return c();
n=function(){v(d,function(a){g+a>=h||m(b[q[g+a]],p(f))})}}n()}function X(b,d,a,c){function e(b){return function(c,e){if(!l){h[b]=e;if(c)return l=!0,a(c);++g>=f&&(l=!0,a(null,h))}}}a=a||function(){};var f=0,h=[],k=0,g=0,l=!1,m=c?d.bind(c):d;d=function(a){m(a,p(e(k++)))};if(r(b)){f=b.length;if(!f)return a(null,h);w(b,d)}else{c=s(b);f=c.length;if(!f)return a(null,h);A(b,d,c)}}function Y(b,d,a,c){function e(b){return function(c,e){if(!g){h[b]=e;if(c)return g=!0,a(c);if(++k>=f)return g=!0,a(null,h);m()}}}
a=a||function(){};var f=0,h=[],k=0,g=!1,l=c?d.bind(c):d,m;if(r(b)){f=b.length;if(!f)return a(null,h);m=function(){l(b[k],p(e(k)))}}else{var n=s(b),f=n.length;if(!f)return a(null,h);m=function(){l(b[n[k]],p(e(k)))}}m()}function Z(b,d,a,c,e){function f(a){return function(b,e){if(!m){k[a]=e;if(b)return m=!0,c(b);if(++g>=h)return m=!0,c(null,k);g>=l+d&&(l=g,q())}}}c=c||function(){};var h=0,k=[],g=0,l=0,m=!1,n=e?a.bind(e):a,q;if(r(b)){h=b.length;if(!h)return c(null,k);q=function(){v(d,function(a){l+a>=
h||(a=l+a,n(b[a],p(f(a))))})}}else{var u=s(b),h=u.length;if(!h)return c(null,k);q=function(){v(d,function(a){l+a>=h||(a=l+a,n(b[u[a]],p(f(a))))})}}q()}function I(b){function d(a,b,h,d){h=c(a,h);J(a,b,h,d)}function a(a,b,h,d,g){d=c(a,d);K(a,b,h,d,g)}function c(a,b){return function(c){b(r(a)?c:z(c))}}switch(b){case "series":return d;case "limit":return a;default:return function(a,b,d,k){d=c(a,d);L(a,b,d,k)}}}function M(b,d,a,c,e){a=a||function(){};var f=0,h=0,k=!1,g=function(){function b(c){return function(b){if(!k){if(!b)return k=
!0,a(c);++h>=f&&(k=!0,a())}}}function c(b){return function(c){if(!k){if(c)return k=!0,a(b);++h>=f&&(k=!0,a())}}}return e?b:c}(),l=c?d.bind(c):d;d=function(a){l(a,p(g(a)))};if(r(b)){f=b.length;if(!f)return a();w(b,d)}else{f=s(b).length;if(!f)return a();A(b,d)}}function N(b,d,a,c,e){a=a||function(){};var f=0,h=0,k=!1,g=function(){function b(c){return function(b){if(!k){if(!b)return k=!0,a(c);if(++h>=f)return k=!0,a();m()}}}function c(b){return function(c){if(!k){if(c)return k=!0,a(b);if(++h>=f)return k=
!0,a();m()}}}return e?b:c}(),l=c?d.bind(c):d,m;if(r(b)){f=b.length;if(!f)return a([]);m=function(){var a=b[h];l(a,p(g(a)))}}else{var n=s(b),f=n.length;if(!f)return a({});m=function(){var a=b[n[h]];l(a,p(g(a)))}}m()}function O(b,d,a,c,e,f){c=c||function(){};var h=0,k=0,g=0,l=!1,m=function(){function a(b){return function(a){if(!l){if(!a)return l=!0,c(b);if(++k>=h)return c();k>=g+d&&(g=k,q())}}}function b(a){return function(b){if(!l){if(b)return l=!0,c(a);if(++k>=h)return c();k>=g+d&&(g=k,q())}}}return f?
a:b}(),n=e?a.bind(e):a,q;if(r(b)){h=b.length;if(!h)return c();q=function(){v(d,function(a){g+a>=h||(a=b[g+a],n(a,p(m(a))))})}}else{var u=s(b),h=u.length;if(!h)return c();q=function(){v(d,function(a){g+a>=h||(a=b[u[g+a]],n(a,p(m(a))))})}}q()}function L(b,d,a,c,e){a=a||function(){};var f=0,h=r(b),k={},g=0,l=function(){function b(c,d){return function(b){b||(k[c+""]=d);++g>=f&&a(h?z(k):k)}}function c(b,d){return function(c){c&&(k[b+""]=d);++g>=f&&a(h?z(k):k)}}return e?b:c}(),m=c?d.bind(c):d;d=function(a,
b){m(a,p(l(b,a)))};if(h){f=b.length;if(!f)return a([]);w(b,d)}else{f=s(b).length;if(!f)return a({});A(b,d)}}function J(b,d,a,c,e){a=a||function(){};var f=0,h=r(b),k={},g=0,l=function(){function b(c,d){return function(b){b||(k[c+""]=d);if(++g>=f)return a(h?z(k):k);n()}}function c(b,d){return function(c){c&&(k[b+""]=d);if(++g>=f)return a(h?z(k):k);n()}}return e?b:c}(),m=c?d.bind(c):d,n;if(h){f=b.length;if(!f)return a([]);n=function(){var a=b[g];m(a,p(l(g,a)))}}else{var q=s(b),f=q.length;if(!f)return a({});
n=function(){var a=q[g],c=b[a];m(c,p(l(a,c)))}}n()}function K(b,d,a,c,e,f){c=c||function(){};var h=0,k=r(b),g={},l=0,m=0,n=function(){function a(b,e){return function(a){a||(g[b+""]=e);if(++l>=h)return c(k?z(g):g);l>=m+d&&(m=l,u())}}function b(a,e){return function(b){b&&(g[a+""]=e);if(++l>=h)return c(k?z(g):g);l>=m+d&&(m=l,u())}}return f?a:b}(),q=e?a.bind(e):a,u;if(k){h=b.length;if(!h)return c([]);u=function(){v(d,function(a){if(!(m+a>=h)){a=m+a;var c=b[a];q(c,p(n(a,c)))}})}}else{var W=s(b),h=W.length;
if(!h)return c({});u=function(){v(d,function(a){if(!(m+a>=h)){a=W[m+a];var c=b[a];q(c,p(n(a,c)))}})}}u()}function P(b,d,a,c,e){function f(a,b){if(!g){if(a)return g=!0,c(a);if(++k>=h)return g=!0,c(null,b);m(b)}}c=c||function(){};var h=0,k=0,g=!1,l=e?a.bind(e):a,m;if(r(b)){h=b.length;if(!h)return c(null,d);m=function(a){l(a,b[k],p(f))}}else{var n=s(b),h=n.length;if(!h)return c(null,d);m=function(a){l(a,b[n[k]],p(f))}}m(d)}function $(b,d,a,c){function e(b,c){if(!l){if(b)return l=!0,a(b);if(!1===c)return l=
!0,a(null,h?T(k):F(k));++g>=f&&(l=!0,a(null,k))}}a=a||function(){};var f=0,h=r(b),k=h?[]:{},g=0,l=!1,m=c?d.bind(c):d;d=function(a,b){m(k,a,b,p(e))};if(h){f=b.length;if(!f)return a(null,k);w(b,d)}else{c=s(b);f=c.length;if(!f)return a(null,k);A(b,d,c)}}function aa(b,d,a,c){function e(b,c){if(!l){if(b)return l=!0,a(b);if(!1===c||++g>=f)return l=!0,a(null,k);n()}}a=a||function(){};var f=0,h=r(b),k=h?[]:{},g=0,l=!1,m=c?d.bind(c):d,n;if(h){f=b.length;if(!f)return a(null,k);n=function(){m(k,b[g],g,p(e))}}else{var q=
s(b),f=q.length;if(!f)return a(null,k);n=function(){var a=q[g];m(k,b[a],a,p(e))}}n()}function ba(b,d,a,c,e){function f(a,b){if(!n){if(a)return n=!0,c(a);if(!1===b)return n=!0,c(null,k?T(g):F(g));if(++l>=h)return n=!0,c(null,g);l>=m+d&&(m=l,u())}}c=c||function(){};var h=0,k=r(b),g=k?[]:{},l=0,m=0,n=!1,q=e?a.bind(e):a,u;if(k){h=b.length;if(!h)return c(null,g);u=function(){v(d,function(a){m+a>=h||(a=m+a,q(g,b[a],a,p(f)))})}}else{var t=s(b),h=t.length;if(!h)return c(null,g);u=function(){v(d,function(a){m+
a>=h||(a=t[m+a],q(g,b[a],a,p(f)))})}}u()}function Q(b){function d(a,b,d,g){b=c(b,g);Y(a,b,e(d))}function a(a,b,d,g,l){d=c(d,l);Z(a,b,d,e(g))}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,g){b=c(b,g);X(a,b,e(d))}}}
function R(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 ca(){var b=arguments;return function(){var d=this,a=E(arguments),c=a.pop();P(b,a,function(a,b,c){a.push(function(a){var b=x(arguments,1);c(a,b)});b.apply(d,a)},function(a,b){b=r(b)?b:[b];b.unshift(a);c.apply(d,b)})}}function da(b){var d="series"===b?H:G;return function(a){var b=this,e=x(arguments,1),f=e.pop()||function(){};d(a,function(a,d){a.apply(b,e.concat(d))},f)}}function ea(b,d,a){function c(a,
b,c){e.started=!0;var d=r(a)?a:[a];if(!a||!d.length)return y(function(){t(e.drain)&&e.drain()});c=t(c)?c:null;w(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});t(e.saturated)&&e.length()>=e.concurrency&&e.saturated();y(e.process)})}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);t(e.drain)&&e.idle()&&e.drain();e.process()}if(!(e.paused||f>=e.concurrency||0===e.length())){var b=e.tasks.shift();t(e.empty)&&e.length()&&e.empty();f++;(e._thisArg?e._worker.bind(e._thisArg):e._worker)(b.task,p(a))}},length:function(){return e.tasks.length},runnning:function(){return f},idle:function(){return 0===e.length()+f},pause:function(){e.paused=!0},resume:function(){!1!==e.paused&&(e.paused=!1,v(e.concurrency,function(){C.setImmediate(e.process)}))},
_worker:b,_thisArg:a},f=0;return e}function fa(b,d,a,c){function e(c){return function(d,n){if(!h){f[c]=n;if(d)return h=!0,a(d);if(++k>=b)return h=!0,a(null,f);g(k,p(e(k)))}}}a=a||function(){};var f=[];if(1>b)return a(null,f);var h=!1,k=0,g=c?d.bind(c):d;g(k,p(e(k)))}function S(b){function d(a){var c=x(arguments,1);console&&(a?console.error?console.error(a):console.log&&console.log(a):console[b]&&w(c,console[b]))}return function(a){var b=x(arguments,1);b.push(d);a.apply(null,b)}}var B=this,ia=B&&B.async,
D,y;(function(){process&&process.nextTick?(D=process.nextTick,y=t(setImmediate)?function(b){setImmediate(b)}:D):y=D=t(setImmediate)?function(b){setImmediate(b)}:function(b){setTimeout(b,0)}})();var C={each:G,eachSeries:H,eachLimit:V,forEach:G,forEachSeries:H,forEachLimit:V,map:X,mapSeries:Y,mapLimit:Z,filter:I(),filterSeries:I("series"),filterLimit:I("limit"),reject:function(b,d,a,c){L(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:M,
detectSeries:N,detectLimit:O,pick:L,pickSeries:J,pickLimit:K,reduce:P,reduceRight:function(b,d,a,c,e){function f(a,b){if(!g){if(a)return g=!0,c(a);if(++k>=h)return g=!0,c(null,b);m(b)}}c=c||function(){};var h=0,k=0,g=!1,l=e?a.bind(e):a,m;if(r(b)){h=b.length;if(!h)return c(null,d);m=function(a){l(a,b[h-k-1],p(f))}}else{var n=s(b),h=n.length;if(!h)return c(null,d);m=function(a){l(a,b[n[h-k-1]],p(f))}}m(d)},transform:$,transformSeries:aa,transformLimit:ba,sortBy:Q(),sortBySeries:Q("series"),sortByLimit:Q("limit"),
some:function(b,d,a,c){M(b,d,function(b){a(!!b)},c)},someSeries:function(b,d,a,c){N(b,d,function(b){a(!!b)},c)},someLimit:function(b,d,a,c,e){O(b,d,a,function(a){c(!!a)},e)},every:function(b,d,a,c){M(b,d,function(b){a(!b)},c,!0)},everySeries:function(b,d,a,c){N(b,d,function(b){a(!b)},c,!0)},everyLimit:function(b,d,a,c,e){O(b,d,a,function(a){c(!a)},e,!0)},concat:function(b,d,a,c){function e(b,c){if(!g){if(b)return g=!0,a(b);r(c)&&c.length&&Array.prototype.push.apply(h,c);++k>=f&&(g=!0,a(null,h))}}
a=a||function(){};var f=0,h=[],k=0,g=!1,l=c?d.bind(c):d;d=function(a){l(a,p(e))};if(r(b)){f=b.length;if(!f)return a(null,h);w(b,d)}else{c=s(b);f=c.length;if(!f)return a(null,h);A(b,d,c)}},concatSeries:function(b,d,a,c){function e(b,c){if(!l){if(b)return l=!0,a(b);r(c)&&c.length&&Array.prototype.push.apply(k,c);if(++g>=f)return l=!0,a(null,k);n()}}a=a||function(){};var f=0,h=r(b),k=[],g=0,l=!1,m=c?d.bind(c):d,n;if(h)f=b.length,n=function(){m(b[g],p(e))};else{var q=s(b),f=q.length;n=function(){m(b[q[g]],
p(e))}}if(!f)return a(null,k);n()},concatLimit:function(b,d,a,c,e){function f(a,b){if(!n){if(a)return n=!0,c(a);r(b)&&b.length&&Array.prototype.push.apply(g,b);if(++l>=h)return n=!0,c(null,g);l>=m+d&&(m=l,u())}}c=c||function(){};var h=0,k=r(b),g=[],l=0,m=0,n=!1,q=e?a.bind(e):a,u;if(k){h=b.length;if(!h)return c(null,g);u=function(){v(d,function(a){m+a>=h||q(b[m+a],p(f))})}}else{var t=s(b),h=t.length;if(!h)return c(null,g);u=function(){v(d,function(a){m+a>=h||q(b[t[m+a]],p(f))})}}u()},parallel:function(b,
d,a){var c=R(a);$(b,c,d,a)},series:function(b,d,a){var c=R(a);aa(b,c,d,a)},parallelLimit:function(b,d,a,c){var e=R(c);ba(b,d,e,a,c)},waterfall:function(b,d,a){var c=function(){return a?function(b,c,d){function k(a){if(a)return d(a);var c=x(arguments,1);b.args=c;d(null,b)}var g=b.args||[];switch(g.length){case 0:return c.call(a,k);case 1:return c.call(a,g[0],k);case 2:return c.call(a,g[0],g[1],k);case 3:return c.call(a,g[0],g[1],g[2],k);case 4:return c.call(a,g[0],g[1],g[2],g[3],k);case 5:return c.call(a,
g[0],g[1],g[2],g[3],g[4],k);default:return g.push(k),c.apply(a,g)}}:function(a,b,c){function d(b){if(b)return c(b);var f=x(arguments,1);a.args=f;c(null,a)}var g=a.args||[];switch(g.length){case 0:return b(d);case 1:return b(g[0],d);case 2:return b(g[0],g[1],d);case 3:return b(g[0],g[1],g[2],d);case 4:return b(g[0],g[1],g[2],g[3],d);case 5:return b(g[0],g[1],g[2],g[3],g[4],d);default:return g.push(d),b.apply(null,g)}}}();P(b,{},c,function(b,c){if(b)return d(b);var h=c.args||[];h.unshift(b);d.apply(a,
h)})},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=x(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=x(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 ca.apply(null,ga(arguments))},seq:ca,applyEach:da(),applyEachSeries:da("series"),queue:function(b,d,a){function c(a,b,c){e.started=!0;var d=r(a)?a:[a];if(!a||!d.length)return y(function(){t(e.drain)&&e.drain()});b=t(b)?b:null;w(d,function(a){a={task:a,callback:b};c?e.tasks.unshift(a):e.tasks.push(a);
t(e.saturated)&&e.length()>=e.concurrency&&e.saturated();y(e.process)})}var e=ea(b,d,a);e.unshift=function(a,b){c(a,b,!0)};e.push=function(a,b){c(a,b)};return e},priorityQueue:ea,cargo:function(b,d){var a={tasks:[],payload:d,saturated:null,empty:null,drain:null,drained:!0,push:function(b,c){b=r(b)?b:[b];c=t(c)?c:null;w(b,function(b){a.tasks.push({data:b,callback:c});a.drained=!1;t(a.saturated)&&a.length()===a.payload&&a.saturated()});y(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");t(a.empty)&&a.empty();c=!0;b(f,function(){c=!1;var b=arguments;w(e,function(a){a.callback&&a.callback.apply(null,b)});a.process()})}else t(a.drain)&&!a.drained&&a.drain(),a.drained=!0},length:function(){return a.tasks.length},runnning:function(){return c}},c=!1;return a},auto:function(b,d){function a(a){h.unshift(a)}function c(){f--;w(h.slice(0),function(a){a()})}d=d?p(d):function(){};var e=s(b),f=e.length;if(!f)return d();var h=[],k={};a(function(){f||
d(null,k)});A(b,function(b,e){function f(a){var b=x(arguments,1);1>=b.length&&(b=b[0]);if(a){var g=F(k);g[e]=b;return d(a,g)}k[e]=b;y(c)}function n(){return!k.hasOwnProperty(e)&&ha(s,function(a){return k.hasOwnProperty(a)})}function q(){if(n()){var a;a:{a=-1;for(var b=h.length;++a<b;)if(h[a]===q)break a;a=-1}0<=a&&h.splice(a,1);t(f,k)}}b=r(b)?b:[b];var p=b.length,s=b.slice(0,p-1),t=b[p-1];if(n())return t(f,k);a(q)},e)},retry:function(b,d,a){function c(c,f){a=c||a||function(){};var h,k;fa(b,function(a,
c){d(function(d,e){h=d;k=e;if(!d)return c(!0);c(d&&a===b-1)},f)},function(){a(h,k)})}t(b)&&(a=d,d=b,b=5);b=parseInt(b,10)||5;return t(a)?c():c},iterator:function(b){function d(c){var e=function(){a&&b[c].apply(null,arguments);return e.next()};e.next=function(){return c<a-1?d(c+1):null};return e}var a=0,c=0;if(r(b))a=b.length;else var e=s(b),a=e.length,c=e[c];return d(c)},apply:function(b){var d=x(arguments,1);return function(){b.apply(null,Array.prototype.concat.apply(d,E(arguments)))}},nextTick:D,
setImmediate:y,times:function(b,d,a,c){function e(c){return function(d,e){if(!h){f[c]=e;if(d)return h=!0,a(d);++k>=b&&(h=!0,a(null,f))}}}a=a||function(){};var f=[];if(1>b)return a(null,f);var h=!1,k=0,g=c?d.bind(c):d;v(b,function(a){g(a,p(e(a)))})},timesSeries:fa,timesLimit:function(b,d,a,c,e){function f(a){return function(e,f){if(!k){h[a]=f;if(e)return k=!0,c(e);if(++g>=b)return k=!0,c(null,h);g>=l+d&&(l=g,n())}}}c=c||function(){};var h=[];if(1>b)return c(null,h);var k=!1,g=0,l=0,m=e?a.bind(e):a,
n=function(){v(d,function(a){l+a>=b||(a=l+a,m(a,p(f(a))))})};n()},memoize:function(b,d,a){d=d||function(a){return a};var c={},e={},f=function(){function f(){c[l]=arguments;var b=e[l];delete e[l];for(var d=-1,g=b.length;++d<g;)b[d].apply(a,arguments)}var k=E(arguments),g=k.pop(),l=d.apply(null,k);if(c.hasOwnProperty(l))D(function(){g.apply(a,c[l])});else{if(e.hasOwnProperty(l))return e[l].push(g);e[l]=[g];k.push(f);b.apply(a,k)}};f.memo=c;f.unmemoized=b;return f},unmemoize:function(b){return function(){return(b.unmemoized||
function p(b){var d=!1;return function(){if(d){if(arguments[0])return b.apply(B,arguments);throw Error("Callback was already called.");}d=!0;b.apply(B,arguments)}}function G(b,d,a,c){function e(b,c){if(!k){if(b)return k=!0,a(b);if(!1===c)return k=!0,a();++h>=f&&(k=!0,a())}}a=a||function(){};var f=0,h=0,k=!1,g=c?d.bind(c):d;d=function(a){g(a,p(e))};if(r(b)){f=b.length;if(!f)return a();w(b,d)}else{c=s(b);f=c.length;if(!f)return a();A(b,d,c)}}function H(b,d,a,c){function e(b,c){if(!k){if(b)return k=
!0,a(b);if(!1===c||++h>=f)return k=!0,a();l()}}a=a||function(){};var f=0,h=0,k=!1,g=c?d.bind(c):d,l;if(r(b)){f=b.length;if(!f)return a();l=function(){g(b[h],p(e))}}else{var m=s(b),f=m.length;if(!f)return a();l=function(){g(b[m[h]],p(e))}}l()}function V(b,d,a,c,e){function f(a,b){if(!l){if(a)return l=!0,c(a);if(!1===b||++k>=h)return l=!0,c();k>=g+d&&(g=k,n())}}c=c||function(){};var h=0,k=0,g=0,l=!1,m=e?a.bind(e):a,n;if(r(b)){h=b.length;if(!h)return c();n=function(){v(d,function(a){g+a>=h||m(b[g+a],
p(f))})}}else{var q=s(b),h=q.length;if(!h)return c();n=function(){v(d,function(a){g+a>=h||m(b[q[g+a]],p(f))})}}n()}function X(b,d,a,c){function e(b){return function(c,e){if(!l){h[b]=e;if(c)return l=!0,a(c);++g>=f&&(l=!0,a(null,h))}}}a=a||function(){};var f=0,h=[],k=0,g=0,l=!1,m=c?d.bind(c):d;d=function(a){m(a,p(e(k++)))};if(r(b)){f=b.length;if(!f)return a(null,h);w(b,d)}else{c=s(b);f=c.length;if(!f)return a(null,h);A(b,d,c)}}function Y(b,d,a,c){function e(b){return function(c,e){if(!g){h[b]=e;if(c)return g=
!0,a(c);if(++k>=f)return g=!0,a(null,h);m()}}}a=a||function(){};var f=0,h=[],k=0,g=!1,l=c?d.bind(c):d,m;if(r(b)){f=b.length;if(!f)return a(null,h);m=function(){l(b[k],p(e(k)))}}else{var n=s(b),f=n.length;if(!f)return a(null,h);m=function(){l(b[n[k]],p(e(k)))}}m()}function Z(b,d,a,c,e){function f(a){return function(b,e){if(!m){k[a]=e;if(b)return m=!0,c(b);if(++g>=h)return m=!0,c(null,k);g>=l+d&&(l=g,q())}}}c=c||function(){};var h=0,k=[],g=0,l=0,m=!1,n=e?a.bind(e):a,q;if(r(b)){h=b.length;if(!h)return c(null,
k);q=function(){v(d,function(a){l+a>=h||(a=l+a,n(b[a],p(f(a))))})}}else{var u=s(b),h=u.length;if(!h)return c(null,k);q=function(){v(d,function(a){l+a>=h||(a=l+a,n(b[u[a]],p(f(a))))})}}q()}function I(b){function d(a,b,h,d){h=c(a,h);J(a,b,h,d)}function a(a,b,h,d,g){d=c(a,d);K(a,b,h,d,g)}function c(a,b){return function(c){b(r(a)?c:z(c))}}switch(b){case "series":return d;case "limit":return a;default:return function(a,b,d,k){d=c(a,d);L(a,b,d,k)}}}function M(b,d,a,c,e){a=a||function(){};var f=0,h=0,k=
!1,g=function(){function b(c){return function(b){if(!k){if(!b)return k=!0,a(c);++h>=f&&(k=!0,a())}}}function c(b){return function(c){if(!k){if(c)return k=!0,a(b);++h>=f&&(k=!0,a())}}}return e?b:c}(),l=c?d.bind(c):d;d=function(a){l(a,p(g(a)))};if(r(b)){f=b.length;if(!f)return a();w(b,d)}else{f=s(b).length;if(!f)return a();A(b,d)}}function N(b,d,a,c,e){a=a||function(){};var f=0,h=0,k=!1,g=function(){function b(c){return function(b){if(!k){if(!b)return k=!0,a(c);if(++h>=f)return k=!0,a();m()}}}function c(b){return function(c){if(!k){if(c)return k=
!0,a(b);if(++h>=f)return k=!0,a();m()}}}return e?b:c}(),l=c?d.bind(c):d,m;if(r(b)){f=b.length;if(!f)return a([]);m=function(){var a=b[h];l(a,p(g(a)))}}else{var n=s(b),f=n.length;if(!f)return a({});m=function(){var a=b[n[h]];l(a,p(g(a)))}}m()}function O(b,d,a,c,e,f){c=c||function(){};var h=0,k=0,g=0,l=!1,m=function(){function a(b){return function(a){if(!l){if(!a)return l=!0,c(b);if(++k>=h)return c();k>=g+d&&(g=k,q())}}}function b(a){return function(b){if(!l){if(b)return l=!0,c(a);if(++k>=h)return c();
k>=g+d&&(g=k,q())}}}return f?a:b}(),n=e?a.bind(e):a,q;if(r(b)){h=b.length;if(!h)return c();q=function(){v(d,function(a){g+a>=h||(a=b[g+a],n(a,p(m(a))))})}}else{var u=s(b),h=u.length;if(!h)return c();q=function(){v(d,function(a){g+a>=h||(a=b[u[g+a]],n(a,p(m(a))))})}}q()}function L(b,d,a,c,e){a=a||function(){};var f=0,h=r(b),k={},g=0,l=function(){function b(c,d){return function(b){b||(k[c+""]=d);++g>=f&&a(h?z(k):k)}}function c(b,d){return function(c){c&&(k[b+""]=d);++g>=f&&a(h?z(k):k)}}return e?b:c}(),
m=c?d.bind(c):d;d=function(a,b){m(a,p(l(b,a)))};if(h){f=b.length;if(!f)return a([]);w(b,d)}else{f=s(b).length;if(!f)return a({});A(b,d)}}function J(b,d,a,c,e){a=a||function(){};var f=0,h=r(b),k={},g=0,l=function(){function b(c,d){return function(b){b||(k[c+""]=d);if(++g>=f)return a(h?z(k):k);n()}}function c(b,d){return function(c){c&&(k[b+""]=d);if(++g>=f)return a(h?z(k):k);n()}}return e?b:c}(),m=c?d.bind(c):d,n;if(h){f=b.length;if(!f)return a([]);n=function(){var a=b[g];m(a,p(l(g,a)))}}else{var q=
s(b),f=q.length;if(!f)return a({});n=function(){var a=q[g],c=b[a];m(c,p(l(a,c)))}}n()}function K(b,d,a,c,e,f){c=c||function(){};var h=0,k=r(b),g={},l=0,m=0,n=function(){function a(b,e){return function(a){a||(g[b+""]=e);if(++l>=h)return c(k?z(g):g);l>=m+d&&(m=l,u())}}function b(a,e){return function(b){b&&(g[a+""]=e);if(++l>=h)return c(k?z(g):g);l>=m+d&&(m=l,u())}}return f?a:b}(),q=e?a.bind(e):a,u;if(k){h=b.length;if(!h)return c([]);u=function(){v(d,function(a){if(!(m+a>=h)){a=m+a;var c=b[a];q(c,p(n(a,
c)))}})}}else{var W=s(b),h=W.length;if(!h)return c({});u=function(){v(d,function(a){if(!(m+a>=h)){a=W[m+a];var c=b[a];q(c,p(n(a,c)))}})}}u()}function P(b,d,a,c,e){function f(a,b){if(!g){if(a)return g=!0,c(a);if(++k>=h)return g=!0,c(null,b);m(b)}}c=c||function(){};var h=0,k=0,g=!1,l=e?a.bind(e):a,m;if(r(b)){h=b.length;if(!h)return c(null,d);m=function(a){l(a,b[k],p(f))}}else{var n=s(b),h=n.length;if(!h)return c(null,d);m=function(a){l(a,b[n[k]],p(f))}}m(d)}function $(b,d,a,c){function e(b,c){if(!l){if(b)return l=
!0,a(b);if(!1===c)return l=!0,a(null,h?T(k):F(k));++g>=f&&(l=!0,a(null,k))}}a=a||function(){};var f=0,h=r(b),k=h?[]:{},g=0,l=!1,m=c?d.bind(c):d;d=function(a,b){m(k,a,b,p(e))};if(h){f=b.length;if(!f)return a(null,k);w(b,d)}else{c=s(b);f=c.length;if(!f)return a(null,k);A(b,d,c)}}function aa(b,d,a,c){function e(b,c){if(!l){if(b)return l=!0,a(b);if(!1===c||++g>=f)return l=!0,a(null,k);n()}}a=a||function(){};var f=0,h=r(b),k=h?[]:{},g=0,l=!1,m=c?d.bind(c):d,n;if(h){f=b.length;if(!f)return a(null,k);n=
function(){m(k,b[g],g,p(e))}}else{var q=s(b),f=q.length;if(!f)return a(null,k);n=function(){var a=q[g];m(k,b[a],a,p(e))}}n()}function ba(b,d,a,c,e){function f(a,b){if(!n){if(a)return n=!0,c(a);if(!1===b)return n=!0,c(null,k?T(g):F(g));if(++l>=h)return n=!0,c(null,g);l>=m+d&&(m=l,u())}}c=c||function(){};var h=0,k=r(b),g=k?[]:{},l=0,m=0,n=!1,q=e?a.bind(e):a,u;if(k){h=b.length;if(!h)return c(null,g);u=function(){v(d,function(a){m+a>=h||(a=m+a,q(g,b[a],a,p(f)))})}}else{var t=s(b),h=t.length;if(!h)return c(null,
g);u=function(){v(d,function(a){m+a>=h||(a=t[m+a],q(g,b[a],a,p(f)))})}}u()}function Q(b){function d(a,b,d,g){b=c(b,g);Y(a,b,e(d))}function a(a,b,d,g,l){d=c(d,l);Z(a,b,d,e(g))}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,g){b=c(b,g);X(a,b,e(d))}}}function R(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 ca(){var b=arguments;return function(){var d=this,a=E(arguments),c=a.pop();P(b,a,function(a,b,c){a.push(function(a){var b=x(arguments,1);c(a,b)});b.apply(d,a)},function(a,b){b=r(b)?b:[b];b.unshift(a);c.apply(d,b)})}}function da(b){var d="series"===b?H:G;return function(a){var b=this,e=x(arguments,1),f=e.pop()||function(){};d(a,function(a,d){a.apply(b,e.concat(d))},
f)}}function ea(b,d,a){function c(a,b,c){e.started=!0;var d=r(a)?a:[a];if(!a||!d.length)return y(function(){t(e.drain)&&e.drain()});c=t(c)?c:null;w(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});t(e.saturated)&&e.length()>=e.concurrency&&e.saturated();y(e.process)})}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);t(e.drain)&&e.idle()&&e.drain();e.process()}if(!(e.paused||f>=e.concurrency||0===e.length())){var b=e.tasks.shift();t(e.empty)&&e.length()&&e.empty();f++;(e._thisArg?e._worker.bind(e._thisArg):e._worker)(b.task,p(a))}},length:function(){return e.tasks.length},runnning:function(){return f},idle:function(){return 0===e.length()+f},pause:function(){e.paused=!0},resume:function(){!1!==e.paused&&(e.paused=!1,v(e.concurrency,
function(){C.setImmediate(e.process)}))},_worker:b,_thisArg:a},f=0;return e}function fa(b,d,a,c){function e(c){return function(d,n){if(!h){f[c]=n;if(d)return h=!0,a(d);if(++k>=b)return h=!0,a(null,f);g(k,p(e(k)))}}}a=a||function(){};var f=[];if(1>b)return a(null,f);var h=!1,k=0,g=c?d.bind(c):d;g(k,p(e(k)))}function S(b){function d(a){var c=x(arguments,1);console&&(a?console.error?console.error(a):console.log&&console.log(a):console[b]&&w(c,console[b]))}return function(a){var b=x(arguments,1);b.push(d);
a.apply(null,b)}}var B=this,ia=B&&B.async,D,y;(function(){process&&process.nextTick?(D=process.nextTick,y=t(setImmediate)?function(b){setImmediate(b)}:D):y=D=t(setImmediate)?function(b){setImmediate(b)}:function(b){setTimeout(b,0)}})();var C={each:G,eachSeries:H,eachLimit:V,forEach:G,forEachSeries:H,forEachLimit:V,map:X,mapSeries:Y,mapLimit:Z,filter:I(),filterSeries:I("series"),filterLimit:I("limit"),reject:function(b,d,a,c){L(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:M,detectSeries:N,detectLimit:O,pick:L,pickSeries:J,pickLimit:K,reduce:P,reduceRight:function(b,d,a,c,e){function f(a,b){if(!g){if(a)return g=!0,c(a);if(++k>=h)return g=!0,c(null,b);m(b)}}c=c||function(){};var h=0,k=0,g=!1,l=e?a.bind(e):a,m;if(r(b)){h=b.length;if(!h)return c(null,d);m=function(a){l(a,b[h-k-1],p(f))}}else{var n=s(b),h=n.length;if(!h)return c(null,d);m=function(a){l(a,b[n[h-k-1]],p(f))}}m(d)},transform:$,transformSeries:aa,transformLimit:ba,sortBy:Q(),
sortBySeries:Q("series"),sortByLimit:Q("limit"),some:function(b,d,a,c){M(b,d,function(b){a(!!b)},c)},someSeries:function(b,d,a,c){N(b,d,function(b){a(!!b)},c)},someLimit:function(b,d,a,c,e){O(b,d,a,function(a){c(!!a)},e)},every:function(b,d,a,c){M(b,d,function(b){a(!b)},c,!0)},everySeries:function(b,d,a,c){N(b,d,function(b){a(!b)},c,!0)},everyLimit:function(b,d,a,c,e){O(b,d,a,function(a){c(!a)},e,!0)},concat:function(b,d,a,c){function e(b,c){if(!g){if(b)return g=!0,a(b);r(c)&&c.length&&Array.prototype.push.apply(h,
c);++k>=f&&(g=!0,a(null,h))}}a=a||function(){};var f=0,h=[],k=0,g=!1,l=c?d.bind(c):d;d=function(a){l(a,p(e))};if(r(b)){f=b.length;if(!f)return a(null,h);w(b,d)}else{c=s(b);f=c.length;if(!f)return a(null,h);A(b,d,c)}},concatSeries:function(b,d,a,c){function e(b,c){if(!l){if(b)return l=!0,a(b);r(c)&&c.length&&Array.prototype.push.apply(k,c);if(++g>=f)return l=!0,a(null,k);n()}}a=a||function(){};var f=0,h=r(b),k=[],g=0,l=!1,m=c?d.bind(c):d,n;if(h)f=b.length,n=function(){m(b[g],p(e))};else{var q=s(b),
f=q.length;n=function(){m(b[q[g]],p(e))}}if(!f)return a(null,k);n()},concatLimit:function(b,d,a,c,e){function f(a,b){if(!n){if(a)return n=!0,c(a);r(b)&&b.length&&Array.prototype.push.apply(g,b);if(++l>=h)return n=!0,c(null,g);l>=m+d&&(m=l,u())}}c=c||function(){};var h=0,k=r(b),g=[],l=0,m=0,n=!1,q=e?a.bind(e):a,u;if(k){h=b.length;if(!h)return c(null,g);u=function(){v(d,function(a){m+a>=h||q(b[m+a],p(f))})}}else{var t=s(b),h=t.length;if(!h)return c(null,g);u=function(){v(d,function(a){m+a>=h||q(b[t[m+
a]],p(f))})}}u()},parallel:function(b,d,a){var c=R(a);$(b,c,d,a)},series:function(b,d,a){var c=R(a);aa(b,c,d,a)},parallelLimit:function(b,d,a,c){var e=R(c);ba(b,d,e,a,c)},waterfall:function(b,d,a){var c=function(){return a?function(b,c,d){function k(a){if(a)return d(a);var c=x(arguments,1);b.args=c;d(null,b)}var g=b.args||[];switch(g.length){case 0:return c.call(a,k);case 1:return c.call(a,g[0],k);case 2:return c.call(a,g[0],g[1],k);case 3:return c.call(a,g[0],g[1],g[2],k);case 4:return c.call(a,
g[0],g[1],g[2],g[3],k);case 5:return c.call(a,g[0],g[1],g[2],g[3],g[4],k);default:return g.push(k),c.apply(a,g)}}:function(a,b,c){function d(b){if(b)return c(b);var f=x(arguments,1);a.args=f;c(null,a)}var g=a.args||[];switch(g.length){case 0:return b(d);case 1:return b(g[0],d);case 2:return b(g[0],g[1],d);case 3:return b(g[0],g[1],g[2],d);case 4:return b(g[0],g[1],g[2],g[3],d);case 5:return b(g[0],g[1],g[2],g[3],g[4],d);default:return g.push(d),b.apply(null,g)}}}();P(b,{},c,function(b,c){if(b)return d(b);
var h=c.args||[];h.unshift(b);d.apply(a,h)})},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=x(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=x(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 ca.apply(null,ga(arguments))},seq:ca,applyEach:da(),applyEachSeries:da("series"),queue:function(b,d,a){function c(a,b,c){e.started=!0;var d=r(a)?a:[a];if(!a||!d.length)return y(function(){t(e.drain)&&e.drain()});b=t(b)?b:null;w(d,function(a){a={task:a,callback:b};c?e.tasks.unshift(a):
e.tasks.push(a);t(e.saturated)&&e.length()>=e.concurrency&&e.saturated();y(e.process)})}var e=ea(b,d,a);e.unshift=function(a,b){c(a,b,!0)};e.push=function(a,b){c(a,b)};return e},priorityQueue:ea,cargo:function(b,d){var a={tasks:[],payload:d,saturated:null,empty:null,drain:null,drained:!0,push:function(b,c){b=r(b)?b:[b];c=t(c)?c:null;w(b,function(b){a.tasks.push({data:b,callback:c});a.drained=!1;t(a.saturated)&&a.length()===a.payload&&a.saturated()});y(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");t(a.empty)&&a.empty();c=!0;b(f,function(){c=!1;var b=arguments;w(e,function(a){a.callback&&a.callback.apply(null,b)});a.process()})}else t(a.drain)&&!a.drained&&a.drain(),a.drained=!0},length:function(){return a.tasks.length},runnning:function(){return c}},c=!1;return a},auto:function(b,d){function a(a){h.unshift(a)}function c(){f--;w(h.slice(0),function(a){a()})}d=d?p(d):function(){};var e=s(b),f=e.length;if(!f)return d();var h=
[],k={};a(function(){f||d(null,k)});A(b,function(b,e){function f(a){var b=x(arguments,1);1>=b.length&&(b=b[0]);if(a){var g=F(k);g[e]=b;return d(a,g)}k[e]=b;y(c)}function n(){return!k.hasOwnProperty(e)&&ha(s,function(a){return k.hasOwnProperty(a)})}function q(){if(n()){var a;a:{a=-1;for(var b=h.length;++a<b;)if(h[a]===q)break a;a=-1}0<=a&&h.splice(a,1);t(f,k)}}b=r(b)?b:[b];var p=b.length,s=b.slice(0,p-1),t=b[p-1];if(n())return t(f,k);a(q)},e)},retry:function(b,d,a){function c(c,f){a=c||a||function(){};
var h,k;fa(b,function(a,c){d(function(d,e){h=d;k=e;if(!d)return c(!0);c(d&&a===b-1)},f)},function(){a(h,k)})}t(b)&&(a=d,d=b,b=5);b=parseInt(b,10)||5;return t(a)?c():c},iterator:function(b){function d(c){var e=function(){a&&b[c].apply(null,arguments);return e.next()};e.next=function(){return c<a-1?d(c+1):null};return e}var a=0,c=0;if(r(b))a=b.length;else var e=s(b),a=e.length,c=e[c];return d(c)},apply:function(b){var d=x(arguments,1);return function(){b.apply(null,Array.prototype.concat.apply(d,E(arguments)))}},
nextTick:D,setImmediate:y,times:function(b,d,a,c){function e(c){return function(d,e){if(!h){f[c]=e;if(d)return h=!0,a(d);++k>=b&&(h=!0,a(null,f))}}}a=a||function(){};var f=[];if(1>b)return a(null,f);var h=!1,k=0,g=c?d.bind(c):d;v(b,function(a){g(a,p(e(a)))})},timesSeries:fa,timesLimit:function(b,d,a,c,e){function f(a){return function(e,f){if(!k){h[a]=f;if(e)return k=!0,c(e);if(++g>=b)return k=!0,c(null,h);g>=l+d&&(l=g,n())}}}c=c||function(){};var h=[];if(1>b)return c(null,h);var k=!1,g=0,l=0,m=e?
a.bind(e):a,n=function(){v(d,function(a){l+a>=b||(a=l+a,m(a,p(f(a))))})};n()},memoize:function(b,d,a){d=d||function(a){return a};var c={},e={},f=function(){function f(){c[l]=arguments;var b=e[l];delete e[l];for(var d=-1,g=b.length;++d<g;)b[d].apply(a,arguments)}var k=E(arguments),g=k.pop(),l=d.apply(null,k);if(c.hasOwnProperty(l))D(function(){g.apply(a,c[l])});else{if(e.hasOwnProperty(l))return e[l].push(g);e[l]=[g];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(){B.async=ia;return C}};"undefined"!=typeof module&&module.exports?module.exports=C:"undefined"!=typeof define&&define.amd?define([],function(){return C}):B.async=C}).call(this);

@@ -12,3 +12,2 @@ (function() {

// TODO front対応
var async = {

@@ -331,2 +330,6 @@

if (called) {
if (arguments[0]) {
return func.apply(root, arguments);
}
throw new Error('Callback was already called.');

@@ -333,0 +336,0 @@ }

{
"name": "neo-async",
"version": "0.2.5",
"version": "0.2.6",
"description": "Neo-Async is faster than Async.js",
"main": "index.js",
"scripts": {
"test": "node_modules/mocha/bin/_mocha test/*/ --require intelli-espower-loader"
"test": "make test-cov"
},

@@ -20,4 +20,6 @@ "repository": {

"async": "^0.9.0",
"coveralls": "^2.11.2",
"espower-loader": "^0.10.0",
"intelli-espower-loader": "^0.5.0",
"istanbul": "^0.3.2",
"lodash": "^2.4.1",

@@ -28,2 +30,1 @@ "mocha": "^2.0.1",

}
# Neo-Async
[![Build Status](https://travis-ci.org/suguru03/Neo-Async.svg?branch=master)](https://travis-ci.org/suguru03/Neo-Async)
[![Coverage Status](https://coveralls.io/repos/suguru03/Neo-Async/badge.png?branch=master)](https://coveralls.io/r/suguru03/Neo-Async?branch=master)
Neo-Async is faster than Async.js and has more feature.

@@ -3,0 +6,0 @@

@@ -8,3 +8,5 @@ /* global describe, it */

var asyncjs = require('async');
var timer = require('../util').createTimer();
var util = require('../util');
var timer = util.createTimer();
var speedTest = util.checkSpeed() ? it : it.skip;

@@ -92,3 +94,3 @@ function concatIterator(order) {

it('should execute faster than async.js', function(done) {
speedTest('should execute faster than async.js', function(done) {

@@ -95,0 +97,0 @@ var sample = 500;

@@ -8,3 +8,5 @@ /* global describe, it */

var asyncjs = require('async');
var timer = require('../util').createTimer();
var util = require('../util');
var timer = util.createTimer();
var speedTest = util.checkSpeed() ? it : it.skip;

@@ -83,3 +85,3 @@ function eachIterator(order) {

it('should execute faster than async.js', function(done) {
speedTest('should execute faster than async.js', function(done) {

@@ -86,0 +88,0 @@ var sample = 1000;

@@ -8,3 +8,5 @@ /* global describe, it */

var asyncjs = require('async');
var timer = require('../util').createTimer();
var util = require('../util');
var timer = util.createTimer();
var speedTest = util.checkSpeed() ? it : it.skip;

@@ -85,3 +87,3 @@ function mapIterator(order) {

it('should execute faster than async.js', function(done) {
speedTest('should execute faster than async.js', function(done) {

@@ -88,0 +90,0 @@ var sample = 1000;

/* global describe, it */
'use strict';
var _ = require('lodash');
var assert = require('power-assert');

@@ -140,3 +141,69 @@ var async = require('../../');

it('should execute drain once', function(done) {
var order = [];
var c = async.cargo(function(tasks, callback) {
order.push(tasks);
callback();
}, 3);
var drainCounter = 0;
c.drain = function() {
drainCounter++;
};
var n = 10;
_.times(n, c.push);
assert.strictEqual(c.length(), 10);
setTimeout(function() {
assert.deepEqual(order, [
[0, 1, 2],
[3, 4, 5],
[6, 7, 8],
[9]
]);
assert.strictEqual(drainCounter, 1);
done();
}, 500);
});
it('should execute drain twice', function(done) {
var order = [];
var c = async.cargo(function(tasks, callback) {
order.push(tasks);
callback();
}, 3);
var drainCounter = 0;
c.drain = function() {
drainCounter++;
};
var n = 10;
var loadCargo = _.times.bind(_, n, c.push);
loadCargo();
assert.strictEqual(c.length(), 10);
setTimeout(loadCargo, 50);
setTimeout(function() {
assert.deepEqual(order, [
[0, 1, 2],
[3, 4, 5],
[6, 7, 8],
[9],
[0, 1, 2],
[3, 4, 5],
[6, 7, 8],
[9]
]);
assert.strictEqual(drainCounter, 2);
done();
}, 100);
});
});

@@ -12,3 +12,3 @@ /* global describe, it */

var add2 = function(n, cb) {
assert.equal(n, 3);
assert.strictEqual(n, 3);
setTimeout(function() {

@@ -20,3 +20,3 @@ cb(null, n + 2);

var mul3 = function(n, cb) {
assert.equal(n, 5);
assert.strictEqual(n, 5);
setTimeout(function() {

@@ -28,3 +28,3 @@ cb(null, n * 3);

var add1 = function(n, cb) {
assert.equal(n, 15);
assert.strictEqual(n, 15);
setTimeout(function() {

@@ -41,3 +41,3 @@ cb(null, n + 1);

}
assert.equal(res, 16);
assert.strictEqual(res, 16);
done();

@@ -52,3 +52,3 @@ });

var self = this;
assert.equal(n, 3);
assert.strictEqual(n, 3);
setTimeout(function() {

@@ -60,3 +60,3 @@ cb(null, self.pow(n, 2));

var mul3 = function(n, cb) {
assert.equal(n, 9);
assert.strictEqual(n, 9);
setTimeout(function() {

@@ -69,3 +69,3 @@ cb(null, n * 3);

var self = this;
assert.equal(n, 27);
assert.strictEqual(n, 27);
setTimeout(function() {

@@ -82,3 +82,3 @@ cb(null, self.pow(n, 3));

}
assert.equal(res, 19683);
assert.strictEqual(res, 19683);
done();

@@ -89,6 +89,6 @@ });

it('should cause error', function(done) {
it('should throw error', function(done) {
var add2 = function(n, cb) {
assert.equal(n, 3);
assert.strictEqual(n, 3);
setTimeout(function() {

@@ -100,3 +100,3 @@ cb(null, n + 2);

var mul3 = function(n, cb) {
assert.equal(n, 5);
assert.strictEqual(n, 5);
setTimeout(function() {

@@ -121,3 +121,35 @@ cb(new Error('error'));

});
it('should execute with binding', function(done) {
var testContext = { name: 'foo' };
var add2 = function(n, cb) {
assert.strictEqual(this, testContext);
setTimeout(function() {
cb(null, n + 2);
}, 50);
};
var mul3 = function(n, cb) {
assert.strictEqual(this, testContext);
setTimeout(function() {
cb(null, n * 3);
}, 15);
};
var add2mul3add1 = async.compose(mul3, add2);
add2mul3add1.call(testContext, 3, function(err, result) {
if (err) {
return done(err);
}
assert.strictEqual(this, testContext);
assert.strictEqual(result, 15);
done();
});
});
});

@@ -8,3 +8,5 @@ /* global describe, it */

var asyncjs = require('async');
var timer = require('../util').createTimer();
var util = require('../util');
var timer = util.createTimer();
var speedTest = util.checkSpeed() ? it : it.skip;

@@ -91,3 +93,3 @@ function createTasks(order, numbers) {

it('should execute faster than async.js', function(done) {
speedTest('should execute faster than async.js', function(done) {

@@ -136,2 +138,22 @@ var sample = 1000;

it('should throw error', function(done) {
var order = [];
var numbers = [1, 3, 2, 4];
var tasks = createTasks(order, numbers);
var error = function(callback) {
setTimeout(function() {
callback('error');
}, 25);
};
tasks.splice(2, 0, error);
async.parallel(tasks, function(err) {
assert.ok(err);
assert.deepEqual(order, [1, 2]);
done();
});
});
});

@@ -199,3 +221,3 @@

it('should execute faster than async.js', function(done) {
speedTest('should execute faster than async.js', function(done) {

@@ -247,5 +269,26 @@ var sample = 1000;

});
});
it('should throw error', function(done) {
var order = [];
var numbers = [1, 3, 2, 4];
var tasks = createTasks(order, numbers);
var error = function(callback) {
setTimeout(function() {
callback('error');
}, 25);
};
tasks.splice(2, 0, error);
async.parallelLimit(tasks, 2, function(err) {
assert.ok(err);
assert.deepEqual(order, [1, 3, 2]);
done();
});
});
});

@@ -8,3 +8,2 @@ /* global describe, it */

// TODO test case
describe('#queue', function() {

@@ -26,28 +25,31 @@

var concurrency = 2;
var queue = async.queue(worker, concurrency);
queue.push(1, function(err, arg) {
assert.equal(err, 'err');
assert.equal(arg, 'arg');
assert.strictEqual(err, 'err');
assert.strictEqual(arg, 'arg');
assert.strictEqual(queue.length(), 1);
order.callback.push(1);
});
queue.push(2, function(err, arg) {
assert.equal(err, 'err');
assert.equal(arg, 'arg');
assert.strictEqual(err, 'err');
assert.strictEqual(arg, 'arg');
assert.strictEqual(queue.length(), 2);
order.callback.push(2);
});
queue.push(3, function(err, arg) {
assert.equal(err, 'err');
assert.equal(arg, 'arg');
assert.strictEqual(err, 'err');
assert.strictEqual(arg, 'arg');
assert.strictEqual(queue.length(), 0);
order.callback.push(3);
});
queue.push(4, function(err, arg) {
assert.equal(err, 'err');
assert.equal(arg, 'arg');
assert.strictEqual(err, 'err');
assert.strictEqual(arg, 'arg');
assert.strictEqual(queue.length(), 0);
order.callback.push(4);
});
assert.equal(queue.length(), 4);
assert.equal(queue.concurrency, concurrency);
assert.strictEqual(queue.length(), 4);
assert.strictEqual(queue.concurrency, concurrency);

@@ -57,4 +59,4 @@ queue.drain = function() {

assert.deepEqual(order.process, [2, 1, 4, 3]);
assert.equal(queue.length(), 0);
assert.equal(queue.concurrency, concurrency);
assert.strictEqual(queue.length(), 0);
assert.strictEqual(queue.concurrency, concurrency);
done();

@@ -64,4 +66,57 @@ };

it('should execute queue and cause error', function(done) {
it('should execute queue with default concurrency', function(done) {
var order = {
callback: [],
process: []
};
var delays = [160, 80, 240, 80];
var worker = function(data, callback) {
setTimeout(function() {
order.process.push(data);
callback('err', 'arg');
}, delays.shift());
};
var queue = async.queue(worker);
queue.push(1, function(err, arg) {
assert.strictEqual(err, 'err');
assert.strictEqual(arg, 'arg');
assert.strictEqual(queue.length(), 3);
order.callback.push(1);
});
queue.push(2, function(err, arg) {
assert.strictEqual(err, 'err');
assert.strictEqual(arg, 'arg');
assert.strictEqual(queue.length(), 2);
order.callback.push(2);
});
queue.push(3, function(err, arg) {
assert.strictEqual(err, 'err');
assert.strictEqual(arg, 'arg');
assert.strictEqual(queue.length(), 1);
order.callback.push(3);
});
queue.push(4, function(err, arg) {
assert.strictEqual(err, 'err');
assert.strictEqual(arg, 'arg');
assert.strictEqual(queue.length(), 0);
order.callback.push(4);
});
assert.strictEqual(queue.length(), 4);
assert.strictEqual(queue.concurrency, 1);
queue.drain = function() {
assert.deepEqual(order.callback, [1, 2, 3, 4]);
assert.deepEqual(order.process, [1, 2, 3, 4]);
assert.strictEqual(queue.length(), 0);
assert.strictEqual(queue.concurrency, 1);
done();
};
});
it('should execute queue and throw error', function(done) {
var results = [];

@@ -96,5 +151,60 @@ var iterator = function(task, callback) {

});
it('should execute while changing concurrency', function(done) {
var order = {
callback: [],
process: []
};
var delays = [160, 80, 240, 80];
var worker = function(data, callback) {
setTimeout(function() {
order.process.push(data);
callback('err', 'arg');
}, delays.shift());
};
var queue = async.queue(worker, 2);
queue.push(1, function(err, arg) {
assert.strictEqual(err, 'err');
assert.strictEqual(arg, 'arg');
assert.strictEqual(queue.length(), 1);
queue.concurrency = 1;
order.callback.push(1);
});
queue.push(2, function(err, arg) {
assert.strictEqual(err, 'err');
assert.strictEqual(arg, 'arg');
assert.strictEqual(queue.length(), 2);
order.callback.push(2);
});
queue.push(3, function(err, arg) {
assert.strictEqual(err, 'err');
assert.strictEqual(arg, 'arg');
assert.strictEqual(queue.length(), 1);
order.callback.push(3);
});
queue.push(4, function(err, arg) {
assert.strictEqual(err, 'err');
assert.strictEqual(arg, 'arg');
assert.strictEqual(queue.length(), 0);
order.callback.push(4);
});
assert.strictEqual(queue.length(), 4);
assert.strictEqual(queue.concurrency, 2);
queue.drain = function() {
assert.deepEqual(order.callback, [2, 1, 3, 4]);
assert.deepEqual(order.process, [2, 1, 3, 4]);
assert.strictEqual(queue.length(), 0);
assert.strictEqual(queue.concurrency, 1);
done();
};
});
});
// TODO test..
describe('#priorityQueue', function() {

@@ -108,35 +218,35 @@

};
var iterator = function(task, callback) {
var worker = function(task, callback) {
order.process.push(task);
callback('err', 'arg');
};
var queue = async.priorityQueue(iterator);
var queue = async.priorityQueue(worker);
queue.push(1, 1.4, function(err, arg) {
assert.equal(err, 'err');
assert.equal(arg, 'arg');
assert.equal(queue.length(), 2);
assert.strictEqual(err, 'err');
assert.strictEqual(arg, 'arg');
assert.strictEqual(queue.length(), 2);
order.callback.push(1);
});
queue.push(2, 0.2, function(err, arg) {
assert.equal(err, 'err');
assert.equal(arg, 'arg');
assert.equal(queue.length(), 3);
assert.strictEqual(err, 'err');
assert.strictEqual(arg, 'arg');
assert.strictEqual(queue.length(), 3);
order.callback.push(2);
});
queue.push(3, 3.8, function(err, arg) {
assert.equal(err, 'err');
assert.equal(arg, 'arg');
assert.equal(queue.length(), 0);
assert.strictEqual(err, 'err');
assert.strictEqual(arg, 'arg');
assert.strictEqual(queue.length(), 0);
order.callback.push(3);
});
queue.push(4, 2.9, function(err, arg) {
assert.equal(err, 'err');
assert.equal(arg, 'arg');
assert.equal(queue.length(), 1);
assert.strictEqual(err, 'err');
assert.strictEqual(arg, 'arg');
assert.strictEqual(queue.length(), 1);
order.callback.push(4);
});
assert.equal(queue.length(), 4);
assert.equal(queue.concurrency, 1);
assert.strictEqual(queue.length(), 4);
assert.strictEqual(queue.concurrency, 1);

@@ -146,4 +256,4 @@ queue.drain = function() {

assert.deepEqual(order.callback, [2, 1, 4, 3]);
assert.equal(queue.concurrency, 1);
assert.equal(queue.length(), 0);
assert.strictEqual(queue.concurrency, 1);
assert.strictEqual(queue.length(), 0);
done();

@@ -153,3 +263,57 @@ };

it('should execute queue by priority sequence with concurrency', function(done) {
var order = {
callback: [],
process: []
};
var delays = [160, 80, 240, 80];
var worker = function(task, callback) {
setTimeout(function() {
order.process.push(task);
callback('err', 'arg');
}, delays.shift());
};
var concurrency = 2;
var queue = async.priorityQueue(worker, concurrency);
queue.push(1, 1.4, function(err, arg) {
assert.strictEqual(err, 'err');
assert.strictEqual(arg, 'arg');
assert.strictEqual(queue.length(), 2);
order.callback.push(1);
});
queue.push(2, 0.2, function(err, arg) {
assert.strictEqual(err, 'err');
assert.strictEqual(arg, 'arg');
assert.strictEqual(queue.length(), 1);
order.callback.push(2);
});
queue.push(3, 3.8, function(err, arg) {
assert.strictEqual(err, 'err');
assert.strictEqual(arg, 'arg');
assert.strictEqual(queue.length(), 0);
order.callback.push(3);
});
queue.push(4, 2.9, function(err, arg) {
assert.strictEqual(err, 'err');
assert.strictEqual(arg, 'arg');
assert.strictEqual(queue.length(), 0);
order.callback.push(4);
});
assert.strictEqual(queue.length(), 4);
assert.strictEqual(queue.concurrency, 2);
queue.drain = function() {
assert.deepEqual(order.process, [1, 2, 3, 4]);
assert.deepEqual(order.callback, [1, 2, 3, 4]);
assert.strictEqual(queue.concurrency, 2);
assert.strictEqual(queue.length(), 0);
done();
};
});
});

@@ -29,4 +29,4 @@ /* global describe, it */

}
assert.equal(callCount, 3);
assert.equal(res, message);
assert.strictEqual(callCount, 3);
assert.strictEqual(res, message);
done();

@@ -51,5 +51,5 @@ });

async.retry(times, fn, function(err, res) {
assert.equal(callCount, 3);
assert.equal(err, error + times);
assert.equal(res, success + times);
assert.strictEqual(callCount, 3);
assert.strictEqual(err, error + times);
assert.strictEqual(res, success + times);
done();

@@ -56,0 +56,0 @@ });

@@ -12,3 +12,3 @@ /* global describe, it */

var add2 = function(n, cb) {
assert.equal(n, 3);
assert.strictEqual(n, 3);
setTimeout(function() {

@@ -20,3 +20,3 @@ cb(null, n + 2);

var mul3 = function(n, cb) {
assert.equal(n, 5);
assert.strictEqual(n, 5);
setTimeout(function() {

@@ -28,3 +28,3 @@ cb(null, n * 3);

var add1 = function(n, cb) {
assert.equal(n, 15);
assert.strictEqual(n, 15);
setTimeout(function() {

@@ -41,3 +41,3 @@ cb(null, n + 1);

}
assert.equal(res, 16);
assert.strictEqual(res, 16);
done();

@@ -52,3 +52,3 @@ });

var self = this;
assert.equal(n, 3);
assert.strictEqual(n, 3);
setTimeout(function() {

@@ -60,3 +60,3 @@ cb(null, self.pow(n, 2));

var mul3 = function(n, cb) {
assert.equal(n, 9);
assert.strictEqual(n, 9);
setTimeout(function() {

@@ -69,3 +69,3 @@ cb(null, n * 3);

var self = this;
assert.equal(n, 27);
assert.strictEqual(n, 27);
setTimeout(function() {

@@ -82,3 +82,3 @@ cb(null, self.pow(n, 3));

}
assert.equal(res, 19683);
assert.strictEqual(res, 19683);
done();

@@ -89,6 +89,6 @@ });

it('should cause error', function(done) {
it('should throw error', function(done) {
var add2 = function(n, cb) {
assert.equal(n, 3);
assert.strictEqual(n, 3);
setTimeout(function() {

@@ -100,3 +100,3 @@ cb(null, n + 2);

var mul3 = function(n, cb) {
assert.equal(n, 5);
assert.strictEqual(n, 5);
setTimeout(function() {

@@ -103,0 +103,0 @@ cb(new Error('error'));

@@ -8,3 +8,5 @@ /* global describe, it */

var asyncjs = require('async');
var timer = require('../util').createTimer();
var util = require('../util');
var timer = util.createTimer();
var speedTest = util.checkSpeed() ? it : it.skip;

@@ -91,3 +93,3 @@ function createTasks(order, numbers) {

it('should execute faster than async.js', function(done) {
speedTest('should execute faster than async.js', function(done) {

@@ -94,0 +96,0 @@ var sample = 1000;

@@ -8,3 +8,5 @@ /* global describe, it */

var asyncjs = require('async');
var timer = require('../util').createTimer();
var util = require('../util');
var timer = util.createTimer();
var speedTest = util.checkSpeed() ? it : it.skip;

@@ -60,3 +62,3 @@ function timeItrator(order) {

it('should execute faster than async.js', function(done) {
speedTest('should execute faster than async.js', function(done) {

@@ -63,0 +65,0 @@ var n = 1000;

@@ -8,3 +8,5 @@ /* global describe, it */

var asyncjs = require('async');
var timer = require('../util').createTimer();
var util = require('../util');
var timer = util.createTimer();
var speedTest = util.checkSpeed() ? it : it.skip;

@@ -77,3 +79,3 @@ function createTasks(type, numbers) {

}
assert.equal(res, 10);
assert.strictEqual(res, 10);
done();

@@ -97,3 +99,3 @@ });

}
assert.equal(res, 14);
assert.strictEqual(res, 14);
done();

@@ -112,6 +114,6 @@ });

}
assert.equal(a, 1);
assert.equal(b, 3);
assert.equal(c, 2);
assert.equal(d, 4);
assert.strictEqual(a, 1);
assert.strictEqual(b, 3);
assert.strictEqual(c, 2);
assert.strictEqual(d, 4);
done();

@@ -122,3 +124,3 @@ });

it('should execute faster than async.js', function(done) {
speedTest('should execute faster than async.js', function(done) {

@@ -156,4 +158,4 @@ var sample = 1000;

// result
assert.equal(sum, res1);
assert.equal(sum, res2);
assert.strictEqual(sum, res1);
assert.strictEqual(sum, res2);
assert.ok(result.async.time < result.asyncjs.time);

@@ -160,0 +162,0 @@

@@ -36,1 +36,6 @@ 'use strict';

exports.checkSpeed = function() {
return process.env.CHECK_SPEED == 1;
};

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc