Socket
Socket
Sign inDemoInstall

async

Package Overview
Dependencies
0
Maintainers
5
Versions
92
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.1 to 3.1.0

13

applyEach.js

@@ -37,9 +37,10 @@ 'use strict';

* called when all functions have completed processing.
* @returns {Function} - If only the first argument, `fns`, is provided, it will
* return a function which lets you pass in the arguments as if it were a single
* function call. The signature is `(..args, callback)`. If invoked with any
* arguments, `callback` is required.
* @returns {AsyncFunction} - Returns a function that takes no args other than
* an optional callback, that is the result of applying the `args` to each
* of the functions.
* @example
*
* async.applyEach([enableSearch, updateSchema], 'bucket', (err, results) => {
* const appliedFn = async.applyEach([enableSearch, updateSchema], 'bucket')
*
* appliedFn((err, results) => {
* // results[0] is the results for `enableSearch`

@@ -52,3 +53,3 @@ * // results[1] is the results for `updateSchema`

* buckets,
* async.applyEach([enableSearch, updateSchema]),
* async (bucket) => async.applyEach([enableSearch, updateSchema], bucket)(),
* callback

@@ -55,0 +56,0 @@ * );

@@ -32,7 +32,7 @@ 'use strict';

* called when all functions have completed processing.
* @returns {Function} - If only the first argument is provided, it will return
* a function which lets you pass in the arguments as if it were a single
* function call.
* @returns {AsyncFunction} - A function, that when called, is the result of
* appling the `args` to the list of functions. It takes no args, other than
* a callback.
*/
exports.default = (0, _applyEach2.default)(_mapSeries2.default);
module.exports = exports['default'];

@@ -18,4 +18,4 @@ 'use strict';

var FN_ARGS = /^(?:async\s+)?(?:function)?\s*[^(]*\(\s*([^)]+)\s*\)(?:\s*{)/m;
var ARROW_FN_ARGS = /^(?:async\s+)?(?:function\s+)?\(?\s*([^)^=]+)\s*\)?(?:\s*=>)/m;
var FN_ARGS = /^(?:async\s+)?(?:function)?\s*\w*\s*\(\s*([^)]+)\s*\)(?:\s*{)/;
var ARROW_FN_ARGS = /^(?:async\s+)?\(?\s*([^)=]+)\s*\)?(?:\s*=>)/;
var FN_ARG_SPLIT = /,/;

@@ -22,0 +22,0 @@ var FN_ARG = /(=.+)?(\s*)$/;

@@ -0,1 +1,9 @@

# v3.1.0
- Added `q.pushAsync` and `q.unshiftAsync`, analagous to `q.push` and `q.unshift`, except they always do not accept a callback, and reject if processing the task errors. (#1659)
- Promises returned from `q.push` and `q.unshift` when a callback is not passed now resolve even if an error ocurred. (#1659)
- Fixed a parsing bug in `autoInject` with complicated function bodies (#1663)
- Added ES6+ configuration for Browserify bundlers (#1653)
- Various doc fixes (#1664, #1658, #1665, #1652)
# v3.0.1

@@ -2,0 +10,0 @@

@@ -1,1 +0,1 @@

(function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.async={})})(this,function(e){'use strict';function t(e,...t){return(...n)=>e(...t,...n)}function n(e){return function(...t){var n=t.pop();return e.call(this,t,n)}}function a(e){setTimeout(e,0)}function i(e){return(t,...n)=>e(()=>t(...n))}function r(e){return u(e)?function(...t){const n=t.pop(),a=e.apply(this,t);return s(a,n)}:n(function(t,n){var a;try{a=e.apply(this,t)}catch(t){return n(t)}return a&&"function"==typeof a.then?s(a,n):void n(null,a)})}function s(e,t){return e.then(e=>{l(t,null,e)},e=>{l(t,e&&e.message?e:new Error(e))})}function l(e,t,n){try{e(t,n)}catch(e){Ee(t=>{throw t},e)}}function u(e){return"AsyncFunction"===e[Symbol.toStringTag]}function d(e){return"AsyncGenerator"===e[Symbol.toStringTag]}function c(e){return"function"==typeof e[Symbol.asyncIterator]}function p(e){if("function"!=typeof e)throw new Error("expected a function");return u(e)?r(e):e}function o(e,t=e.length){function n(...n){return"function"==typeof n[t-1]?e.apply(this,n):new Promise((a,i)=>{n[t-1]=(e,...t)=>e?i(e):void a(1<t.length?t:t[0]),e.apply(this,n)})}if(!t)throw new Error("arity is undefined");return Object.defineProperty(n,"name",{value:`awaitable(${e.name})`}),n}function h(e){return function(t,...n){const a=o(function(a){var i=this;return e(t,(e,t)=>{p(e).apply(i,n.concat(t))},a)});return a}}function f(e,t,n,a){t=t||[];var i=[],r=0,s=p(n);return e(t,(e,t,n)=>{var a=r++;s(e,(e,t)=>{i[a]=t,n(e)})},e=>{a(e,i)})}function y(e){return e&&"number"==typeof e.length&&0<=e.length&&0==e.length%1}function m(e){function t(...t){if(null!==e){var n=e;e=null,n.apply(this,t)}}return Object.assign(t,e),t}function g(e){return e[Symbol.iterator]&&e[Symbol.iterator]()}function k(e){var t=-1,n=e.length;return function(){return++t<n?{value:e[t],key:t}:null}}function v(e){var t=-1;return function(){var n=e.next();return n.done?null:(t++,{value:n.value,key:t})}}function S(e){var t=e?Object.keys(e):[],n=-1,a=t.length;return function(){var i=t[++n];return n<a?{value:e[i],key:i}:null}}function L(e){if(y(e))return k(e);var t=g(e);return t?v(t):S(e)}function x(e){return function(...t){if(null===e)throw new Error("Callback was already called.");var n=e;e=null,n.apply(this,t)}}function E(e,t,n,a){function i(){c>=t||d||l||(d=!0,e.next().then(({value:e,done:t})=>{if(!(u||l))return d=!1,t?(l=!0,void(0>=c&&a(null))):void(c++,n(e,p,r),p++,i())}).catch(s))}function r(e,t){return c-=1,u?void 0:e?s(e):!1===e?(l=!0,void(u=!0)):t===be||l&&0>=c?(l=!0,a(null)):void i()}function s(e){u||(d=!1,l=!0,a(e))}let l=!1,u=!1,d=!1,c=0,p=0;i()}function b(e,t,n){function a(e,t){!1===e&&(l=!0);!0===l||(e?n(e):(++r===s||t===be)&&n(null))}n=m(n);var i=0,r=0,{length:s}=e,l=!1;for(0===s&&n(null);i<s;i++)t(e[i],i,x(a))}function O(e,t,n){return _e(e,1/0,t,n)}function _(){function e(e,...a){return e?n(e):void t(1<a.length?a:a[0])}let t,n;return e[Fe]=new Promise((e,a)=>{t=e,n=a}),e}function M(e,t,n){function a(e,t){g.push(()=>l(e,t))}function i(){if(!h){if(0===g.length&&0===o)return n(null,c);for(;g.length&&o<t;){var e=g.shift();e()}}}function r(e,t){var n=y[e];n||(n=y[e]=[]),n.push(t)}function s(e){var t=y[e]||[];t.forEach(e=>e()),i()}function l(e,t){if(!f){var a=x((t,...a)=>{if(o--,!1===t)return void(h=!0);if(2>a.length&&([a]=a),t){var i={};if(Object.keys(c).forEach(e=>{i[e]=c[e]}),i[e]=a,f=!0,y=Object.create(null),h)return;n(t,i)}else c[e]=a,s(e)});o++;var i=p(t[t.length-1]);1<t.length?i(c,a):i(a)}}function u(t){var n=[];return Object.keys(e).forEach(a=>{const i=e[a];Array.isArray(i)&&0<=i.indexOf(t)&&n.push(a)}),n}"number"!=typeof t&&(n=t,t=null),n=m(n||_());var d=Object.keys(e).length;if(!d)return n(null);t||(t=d);var c={},o=0,h=!1,f=!1,y=Object.create(null),g=[],k=[],v={};return Object.keys(e).forEach(t=>{var n=e[t];if(!Array.isArray(n))return a(t,[n]),void k.push(t);var i=n.slice(0,n.length-1),s=i.length;return 0===s?(a(t,n),void k.push(t)):void(v[t]=s,i.forEach(l=>{if(!e[l])throw new Error("async.auto task `"+t+"` has a non-existent dependency `"+l+"` in "+i.join(", "));r(l,()=>{s--,0===s&&a(t,n)})}))}),function(){for(var e,t=0;k.length;)e=k.pop(),t++,u(e).forEach(e=>{0==--v[e]&&k.push(e)});if(t!==d)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}(),i(),n[Fe]}function I(e){const t=e.toString().replace(ze,"");let n=t.match(Pe);if(n||(n=t.match(Te)),!n)throw new Error("could not parse args in autoInject\nSource:\n"+t);let[,a]=n;return a.replace(/\s/g,"").split(Re).map(e=>e.replace(Ce,"").trim())}function A(e,t){var n={};return Object.keys(e).forEach(t=>{function a(e,t){var n=i.map(t=>e[t]);n.push(t),p(r)(...n)}var i,r=e[t],s=u(r),l=!s&&1===r.length||s&&0===r.length;if(Array.isArray(r))i=[...r],r=i.pop(),n[t]=i.concat(0<i.length?a:r);else if(l)n[t]=r;else{if(i=I(r),0===r.length&&!s&&0===i.length)throw new Error("autoInject task functions require explicit parameters.");s||i.pop(),n[t]=i.concat(a)}}),M(n,t)}function j(e,t){e.length=1,e.head=e.tail=t}function w(e,t,n){function a(e,t){h[e].push(t)}function i(e,t){const n=(...a)=>{r(e,n),t(...a)};h[e].push(n)}function r(e,t){return e?t?void(h[e]=h[e].filter(e=>e!==t)):h[e]=[]:Object.keys(h).forEach(e=>h[e]=[])}function s(e,...t){h[e].forEach(e=>e(...t))}function l(e,t,n){if(null!=n&&"function"!=typeof n)throw new Error("task callback must be a function");g.started=!0;var a,i={data:e,callback:n||function(e,...t){return e?void 0:1>=t.length?a(t[0]):void a(t)}};if(t?g._tasks.unshift(i):g._tasks.push(i),f||(f=!0,Ee(()=>{f=!1,g.process()})),!n)return new Promise(e=>{a=e})}function u(e){return function(t,...n){c-=1;for(var a=0,r=e.length;a<r;a++){var l=e[a],u=o.indexOf(l);0===u?o.shift():0<u&&o.splice(u,1),l.callback(t,...n),null!=t&&s("error",t,l.data)}c<=g.concurrency-g.buffer&&s("unsaturated"),g.idle()&&s("drain"),g.process()}}if(null==t)t=1;else if(0===t)throw new RangeError("Concurrency must not be zero");var d=p(e),c=0,o=[];const h={error:[],drain:[],saturated:[],unsaturated:[],empty:[]};var f=!1;const y=e=>t=>t?void(r(e),a(e,t)):new Promise((t,n)=>{i(e,(e,a)=>e?n(e):void t(a))});var m=!1,g={_tasks:new Ye,*[Symbol.iterator](){yield*g._tasks[Symbol.iterator]()},concurrency:t,payload:n,buffer:t/4,started:!1,paused:!1,push(e,t){return Array.isArray(e)?0===e.length&&g.idle()?Ee(()=>s("drain")):e.map(e=>l(e,!1,t)):l(e,!1,t)},kill(){r(),g._tasks.empty()},unshift(e,t){return Array.isArray(e)?0===e.length&&g.idle()?Ee(()=>s("drain")):e.map(e=>l(e,!0,t)):l(e,!0,t)},remove(e){g._tasks.remove(e)},process(){var e=Math.min;if(!m){for(m=!0;!g.paused&&c<g.concurrency&&g._tasks.length;){var t=[],n=[],a=g._tasks.length;g.payload&&(a=e(a,g.payload));for(var r,p=0;p<a;p++)r=g._tasks.shift(),t.push(r),o.push(r),n.push(r.data);c+=1,0===g._tasks.length&&s("empty"),c===g.concurrency&&s("saturated");var h=x(u(t));d(n,h)}m=!1}},length(){return g._tasks.length},running(){return c},workersList(){return o},idle(){return 0===g._tasks.length+c},pause(){g.paused=!0},resume(){!1===g.paused||(g.paused=!1,Ee(g.process))}};return Object.defineProperties(g,{saturated:{writable:!1,value:y("saturated")},unsaturated:{writable:!1,value:y("unsaturated")},empty:{writable:!1,value:y("empty")},drain:{writable:!1,value:y("drain")},error:{writable:!1,value:y("error")}}),g}function B(e,t){return w(e,1,t)}function F(e,t,n){return w(e,t,n)}function P(...e){var t=e.map(p);return function(...e){var n=this,a=e[e.length-1];return"function"==typeof a?e.pop():a=_(),Ne(t,e,(e,t,a)=>{t.apply(n,e.concat((e,...t)=>{a(e,t)}))},(e,t)=>a(e,...t)),a[Fe]}}function T(...e){return P(...e.reverse())}function R(...e){return function(...t){var n=t.pop();return n(null,...e)}}function C(e,t){return(n,a,i,r)=>{var s,l=!1;const u=p(i);n(a,(n,a,i)=>{u(n,(a,r)=>a||!1===a?i(a):e(r)&&!s?(l=!0,s=t(!0,n),i(null,be)):void i())},e=>e?r(e):void r(null,l?s:t(!1)))}}function z(e){return(t,...n)=>p(t)(...n,(t,...n)=>{"object"==typeof console&&(t?console.error&&console.error(t):console[e]&&n.forEach(t=>console[e](t)))})}function Y(e,t,n){const a=p(t);return Je(e,(...e)=>{const t=e.pop();a(...e,(e,n)=>t(e,!n))},n)}function V(e){return(t,n,a)=>e(t,a)}function N(e){return u(e)?e:function(...t){var n=t.pop(),a=!0;t.push((...e)=>{a?Ee(()=>n(...e)):n(...e)}),e.apply(this,t),a=!1}}function q(e,t,n,a){var r=Array(t.length);e(t,(e,t,a)=>{n(e,(e,n)=>{r[t]=!!n,a(e)})},e=>{if(e)return a(e);for(var n=[],s=0;s<t.length;s++)r[s]&&n.push(t[s]);a(null,n)})}function D(e,t,n,a){var i=[];e(t,(e,t,a)=>{n(e,(n,r)=>n?a(n):void(r&&i.push({index:t,value:e}),a(n)))},e=>e?a(e):void a(null,i.sort((e,t)=>e.index-t.index).map(e=>e.value)))}function Q(e,t,n,a){var i=y(t)?q:D;return i(e,t,p(n),a)}function U(e,t,n){return lt(e,1/0,t,n)}function G(e,t,n){return lt(e,1,t,n)}function W(e,t,n){return dt(e,1/0,t,n)}function K(e,t,n){return dt(e,1,t,n)}function X(e,t=e=>e){var a=Object.create(null),r=Object.create(null),s=p(e),l=n((e,n)=>{var u=t(...e);u in a?Ee(()=>n(null,...a[u])):u in r?r[u].push(n):(r[u]=[n],s(...e,(e,...t)=>{e||(a[u]=t);var n=r[u];delete r[u];for(var s=0,d=n.length;s<d;s++)n[s](e,...t)}))});return l.memo=a,l.unmemoized=e,l}function J(e,t){return pt(Me,e,t)}function Z(e,t,n){return pt(Oe(t),e,n)}function $(e,t){var n=p(e);return w((e,t)=>{n(e[0],t)},t,1)}function H(e){return(e<<1)+1}function ee(e){return(e+1>>1)-1}function te(e,t){return e.priority===t.priority?e.pushCount<t.pushCount:e.priority<t.priority}function ne(e,t){var n=$(e,t);return n._tasks=new ot,n.push=function(e,t=0,a=()=>{}){if("function"!=typeof a)throw new Error("task callback must be a function");if(n.started=!0,Array.isArray(e)||(e=[e]),0===e.length&&n.idle())return Ee(()=>n.drain());for(var r,s=0,u=e.length;s<u;s++)r={data:e[s],priority:t,callback:a},n._tasks.push(r);Ee(n.process)},delete n.unshift,n}function ae(e,t,n,a){var i=[...e].reverse();return Ne(i,t,n,a)}function ie(e){var t=p(e);return n(function(e,n){return e.push((e,...t)=>{let a={};if(e&&(a.error=e),0<t.length){var i=t;1>=t.length&&([i]=t),a.value=i}n(null,a)}),t.apply(this,e)})}function re(e){var t;return Array.isArray(e)?t=e.map(ie):(t={},Object.keys(e).forEach(n=>{t[n]=ie.call(this,e[n])})),t}function se(e,t,n,a){const i=p(n);return Q(e,t,(e,t)=>{i(e,(e,n)=>{t(e,!n)})},a)}function le(e){return function(){return e}}function ue(e,t,n){function a(){r((e,...t)=>{!1===e||(e&&s++<i.times&&("function"!=typeof i.errorFilter||i.errorFilter(e))?setTimeout(a,i.intervalFunc(s-1)):n(e,...t))})}var i={times:gt,intervalFunc:le(kt)};if(3>arguments.length&&"function"==typeof e?(n=t||_(),t=e):(de(i,e),n=n||_()),"function"!=typeof t)throw new Error("Invalid arguments for async.retry");var r=p(t),s=1;return a(),n[Fe]}function de(e,n){if("object"==typeof n)e.times=+n.times||gt,e.intervalFunc="function"==typeof n.interval?n.interval:le(+n.interval||kt),e.errorFilter=n.errorFilter;else if("number"==typeof n||"string"==typeof n)e.times=+n||gt;else throw new Error("Invalid arguments for async.retry")}function ce(e,t){t||(t=e,e=null);let a=e&&e.arity||t.length;u(t)&&(a+=1);var i=p(t);return n((t,n)=>{function r(e){i(...t,e)}return(t.length<a-1||null==n)&&(t.push(n),n=_()),e?ue(e,r,n):ue(r,n),n[Fe]})}function pe(e,t){return pt(je,e,t)}function oe(e,t,a){var i=p(e);return n((n,r)=>{var s,l=!1;n.push((...e)=>{l||(r(...e),clearTimeout(s))}),s=setTimeout(function(){var t=e.name||"anonymous",n=new Error("Callback function \""+t+"\" timed out.");n.code="ETIMEDOUT",a&&(n.info=a),l=!0,r(n)},t),i(...n)})}function he(e){for(var t=Array(e);e--;)t[e]=e;return t}function fe(e,t,n,a){var i=p(n);return qe(he(e),t,i,a)}function ye(e,t,n){return fe(e,1/0,t,n)}function me(e,t,n){return fe(e,1,t,n)}function ge(e,t,n,a){3>=arguments.length&&"function"==typeof t&&(a=n,n=t,t=Array.isArray(e)?[]:{}),a=m(a||_());var i=p(n);return Me(e,(e,n,a)=>{i(t,e,n,a)},e=>a(e,t)),a[Fe]}function ke(e){return(...t)=>(e.unmemoized||e)(...t)}function ve(e,t,n){const a=p(e);return bt(e=>a((t,n)=>e(t,!n)),t,n)}var Se,Le="function"==typeof setImmediate&&setImmediate,xe="object"==typeof process&&"function"==typeof process.nextTick;Se=Le?setImmediate:xe?process.nextTick:a;var Ee=i(Se);const be={};var Oe=e=>(t,n,a)=>{function i(e,t){if(!u)if(p-=1,e)l=!0,a(e);else if(!1===e)l=!0,u=!0;else{if(t===be||l&&0>=p)return l=!0,a(null);o||r()}}function r(){for(o=!0;p<e&&!l;){var t=s();if(null===t)return l=!0,void(0>=p&&a(null));p+=1,n(t.value,t.key,x(i))}o=!1}if(a=m(a),0>=e)throw new RangeError("concurrency limit cannot be less than 1");if(!t)return a(null);if(d(t))return E(t,e,n,a);if(c(t))return E(t[Symbol.asyncIterator](),e,n,a);var s=L(t),l=!1,u=!1,p=0,o=!1;r()},_e=o(function(e,t,n,a){return Oe(t)(e,p(n),a)},4),Me=o(function(e,t,n){var a=y(e)?b:O;return a(e,p(t),n)},3),Ie=o(function(e,t,n){return f(Me,e,t,n)},3),Ae=h(Ie),je=o(function(e,t,n){return _e(e,1,t,n)},3),we=o(function(e,t,n){return f(je,e,t,n)},3),Be=h(we);const Fe=Symbol("promiseCallback");var Pe=/^(?:async\s+)?(?:function)?\s*[^(]*\(\s*([^)]+)\s*\)(?:\s*{)/m,Te=/^(?:async\s+)?(?:function\s+)?\(?\s*([^)^=]+)\s*\)?(?:\s*=>)/m,Re=/,/,Ce=/(=.+)?(\s*)$/,ze=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;class Ye{constructor(){this.head=this.tail=null,this.length=0}removeLink(e){return e.prev?e.prev.next=e.next:this.head=e.next,e.next?e.next.prev=e.prev:this.tail=e.prev,e.prev=e.next=null,this.length-=1,e}empty(){for(;this.head;)this.shift();return this}insertAfter(e,t){t.prev=e,t.next=e.next,e.next?e.next.prev=t:this.tail=t,e.next=t,this.length+=1}insertBefore(e,t){t.prev=e.prev,t.next=e,e.prev?e.prev.next=t:this.head=t,e.prev=t,this.length+=1}unshift(e){this.head?this.insertBefore(this.head,e):j(this,e)}push(e){this.tail?this.insertAfter(this.tail,e):j(this,e)}shift(){return this.head&&this.removeLink(this.head)}pop(){return this.tail&&this.removeLink(this.tail)}toArray(){return[...this]}*[Symbol.iterator](){for(var e=this.head;e;)yield e.data,e=e.next}remove(e){for(var t=this.head;t;){var{next:n}=t;e(t)&&this.removeLink(t),t=n}return this}}var Ve,Ne=o(function(e,t,n,a){a=m(a);var r=p(n);return je(e,(e,n,a)=>{r(t,e,(e,n)=>{t=n,a(e)})},e=>a(e,t))},4),qe=o(function(e,t,n,a){return f(Oe(t),e,n,a)},4),De=o(function(e,t,n,a){var i=p(n);return qe(e,t,(e,t)=>{i(e,(e,...n)=>e?t(e):t(e,n))},(e,t)=>{for(var n=[],r=0;r<t.length;r++)t[r]&&(n=n.concat(...t[r]));return a(e,n)})},4),Qe=o(function(e,t,n){return De(e,1/0,t,n)},3),Ue=o(function(e,t,n){return De(e,1,t,n)},3),Ge=o(function(e,t,n){return C(e=>e,(e,t)=>t)(Me,e,t,n)},3),We=o(function(e,t,n,a){return C(e=>e,(e,t)=>t)(Oe(t),e,n,a)},4),Ke=o(function(e,t,n){return C(e=>e,(e,t)=>t)(Oe(1),e,t,n)},3),Xe=z("dir"),Je=o(function(e,t,n){function a(e,...t){return e?n(e):void(!1===e||(r=t,l(...t,i)))}function i(e,t){return e?n(e):!1===e?void 0:t?void s(a):n(null,...r)}n=x(n);var r,s=p(e),l=p(t);return i(null,!0)},3),Ze=o(function(e,t,n){return Me(e,V(p(t)),n)},3),$e=o(function(e,t,n,a){return Oe(t)(e,V(p(n)),a)},4),He=o(function(e,t,n){return $e(e,1,t,n)},3),et=o(function(e,t,n){return C(e=>!e,e=>!e)(Me,e,t,n)},3),tt=o(function(e,t,n,a){return C(e=>!e,e=>!e)(Oe(t),e,n,a)},4),nt=o(function(e,t,n){return C(e=>!e,e=>!e)(je,e,t,n)},3),at=o(function(e,t,n){return Q(Me,e,t,n)},3),it=o(function(e,t,n,a){return Q(Oe(t),e,n,a)},4),rt=o(function(e,t,n){return Q(je,e,t,n)},3),st=o(function(e,t){function n(e){return e?a(e):void(!1===e||i(n))}var a=x(t),i=p(N(e));return n()},2),lt=o(function(e,t,n,a){var i=p(n);return qe(e,t,(e,t)=>{i(e,(n,a)=>n?t(n):t(n,{key:a,val:e}))},(e,t)=>{for(var n={},{hasOwnProperty:r}=Object.prototype,s=0;s<t.length;s++)if(t[s]){var{key:l}=t[s],{val:u}=t[s];r.call(n,l)?n[l].push(u):n[l]=[u]}return a(e,n)})},4),ut=z("log"),dt=o(function(e,t,n,a){a=m(a);var i={},r=p(n);return Oe(t)(e,(e,t,n)=>{r(e,t,(e,a)=>e?n(e):void(i[t]=a,n(e)))},e=>a(e,i))},4);Ve=xe?process.nextTick:Le?setImmediate:a;var ct=i(Ve),pt=o((e,t,n)=>{var a=y(t)?[]:{};e(t,(e,t,n)=>{p(e)((e,...i)=>{2>i.length&&([i]=i),a[t]=i,n(e)})},e=>n(e,a))},3);class ot{constructor(){this.heap=[],this.pushCount=Number.MIN_SAFE_INTEGER}get length(){return this.heap.length}empty(){return this.heap=[],this}percUp(e){for(let n;0<e&&te(this.heap[e],this.heap[n=ee(e)]);){let a=this.heap[e];this.heap[e]=this.heap[n],this.heap[n]=a,e=n}}percDown(e){for(let n,a;(n=H(e))<this.heap.length&&(n+1<this.heap.length&&te(this.heap[n+1],this.heap[n])&&++n,!te(this.heap[e],this.heap[n]));)a=this.heap[e],this.heap[e]=this.heap[n],this.heap[n]=a,e=n}push(e){e.pushCount=++this.pushCount,this.heap.push(e),this.percUp(this.heap.length-1)}unshift(e){return this.heap.push(e)}shift(){let[e]=this.heap;return this.heap[0]=this.heap[this.heap.length-1],this.heap.pop(),this.percDown(0),e}toArray(){return[...this]}*[Symbol.iterator](){for(let e=0;e<this.heap.length;e++)yield this.heap[e].data}remove(e){let t=0;for(let n=0;n<this.heap.length;n++)e(this.heap[n])||(this.heap[t]=this.heap[n],t++);this.heap.splice(t);for(let t=ee(this.heap.length-1);0<=t;t--)this.percDown(t);return this}}var ht=o(function(e,t){if(t=m(t),!Array.isArray(e))return t(new TypeError("First argument to race must be an array of functions"));if(!e.length)return t();for(var n=0,a=e.length;n<a;n++)p(e[n])(t)},2),ft=o(function(e,t,n){return se(Me,e,t,n)},3),yt=o(function(e,t,n,a){return se(Oe(t),e,n,a)},4),mt=o(function(e,t,n){return se(je,e,t,n)},3);const gt=5,kt=0;var vt=o(function(e,t,n){return C(Boolean,e=>e)(Me,e,t,n)},3),St=o(function(e,t,n,a){return C(Boolean,e=>e)(Oe(t),e,n,a)},4),Lt=o(function(e,t,n){return C(Boolean,e=>e)(je,e,t,n)},3),xt=o(function(e,t,n){function a(e,t){var n=e.criteria,a=t.criteria;return n<a?-1:n>a?1:0}var i=p(t);return Ie(e,(e,t)=>{i(e,(n,a)=>n?t(n):void t(n,{value:e,criteria:a}))},(e,t)=>e?n(e):void n(null,t.sort(a).map(e=>e.value)))},3),Et=o(function(e,t){var n,a=null;return He(e,(e,t)=>{p(e)((e,...i)=>!1===e?t(e):void(2>i.length?[n]=i:n=i,a=e,t(e?null:{})))},()=>t(a,n))}),bt=o(function(e,t,n){function a(e,...t){if(e)return n(e);l=t;!1===e||s(i)}function i(e,t){return e?n(e):!1===e?void 0:t?void r(a):n(null,...l)}n=x(n);var r=p(t),s=p(e),l=[];return s(i)},3),Ot=o(function(e,t){function n(t){var n=p(e[i++]);n(...t,x(a))}function a(a,...r){return!1===a?void 0:a||i===e.length?t(a,...r):void n(r)}if(t=m(t),!Array.isArray(e))return t(new Error("First argument to waterfall must be an array of functions"));if(!e.length)return t();var i=0;n([])});e.default={apply:t,applyEach:Ae,applyEachSeries:Be,asyncify:r,auto:M,autoInject:A,cargo:B,cargoQueue:F,compose:T,concat:Qe,concatLimit:De,concatSeries:Ue,constant:R,detect:Ge,detectLimit:We,detectSeries:Ke,dir:Xe,doUntil:Y,doWhilst:Je,each:Ze,eachLimit:$e,eachOf:Me,eachOfLimit:_e,eachOfSeries:je,eachSeries:He,ensureAsync:N,every:et,everyLimit:tt,everySeries:nt,filter:at,filterLimit:it,filterSeries:rt,forever:st,groupBy:U,groupByLimit:lt,groupBySeries:G,log:ut,map:Ie,mapLimit:qe,mapSeries:we,mapValues:W,mapValuesLimit:dt,mapValuesSeries:K,memoize:X,nextTick:ct,parallel:J,parallelLimit:Z,priorityQueue:ne,queue:$,race:ht,reduce:Ne,reduceRight:ae,reflect:ie,reflectAll:re,reject:ft,rejectLimit:yt,rejectSeries:mt,retry:ue,retryable:ce,seq:P,series:pe,setImmediate:Ee,some:vt,someLimit:St,someSeries:Lt,sortBy:xt,timeout:oe,times:ye,timesLimit:fe,timesSeries:me,transform:ge,tryEach:Et,unmemoize:ke,until:ve,waterfall:Ot,whilst:bt,all:et,allLimit:tt,allSeries:nt,any:vt,anyLimit:St,anySeries:Lt,find:Ge,findLimit:We,findSeries:Ke,flatMap:Qe,flatMapLimit:De,flatMapSeries:Ue,forEach:Ze,forEachSeries:He,forEachLimit:$e,forEachOf:Me,forEachOfSeries:je,forEachOfLimit:_e,inject:Ne,foldl:Ne,foldr:ae,select:at,selectLimit:it,selectSeries:rt,wrapSync:r,during:bt,doDuring:Je},e.apply=t,e.applyEach=Ae,e.applyEachSeries=Be,e.asyncify=r,e.auto=M,e.autoInject=A,e.cargo=B,e.cargoQueue=F,e.compose=T,e.concat=Qe,e.concatLimit=De,e.concatSeries=Ue,e.constant=R,e.detect=Ge,e.detectLimit=We,e.detectSeries=Ke,e.dir=Xe,e.doUntil=Y,e.doWhilst=Je,e.each=Ze,e.eachLimit=$e,e.eachOf=Me,e.eachOfLimit=_e,e.eachOfSeries=je,e.eachSeries=He,e.ensureAsync=N,e.every=et,e.everyLimit=tt,e.everySeries=nt,e.filter=at,e.filterLimit=it,e.filterSeries=rt,e.forever=st,e.groupBy=U,e.groupByLimit=lt,e.groupBySeries=G,e.log=ut,e.map=Ie,e.mapLimit=qe,e.mapSeries=we,e.mapValues=W,e.mapValuesLimit=dt,e.mapValuesSeries=K,e.memoize=X,e.nextTick=ct,e.parallel=J,e.parallelLimit=Z,e.priorityQueue=ne,e.queue=$,e.race=ht,e.reduce=Ne,e.reduceRight=ae,e.reflect=ie,e.reflectAll=re,e.reject=ft,e.rejectLimit=yt,e.rejectSeries=mt,e.retry=ue,e.retryable=ce,e.seq=P,e.series=pe,e.setImmediate=Ee,e.some=vt,e.someLimit=St,e.someSeries=Lt,e.sortBy=xt,e.timeout=oe,e.times=ye,e.timesLimit=fe,e.timesSeries=me,e.transform=ge,e.tryEach=Et,e.unmemoize=ke,e.until=ve,e.waterfall=Ot,e.whilst=bt,e.all=et,e.allLimit=tt,e.allSeries=nt,e.any=vt,e.anyLimit=St,e.anySeries=Lt,e.find=Ge,e.findLimit=We,e.findSeries=Ke,e.flatMap=Qe,e.flatMapLimit=De,e.flatMapSeries=Ue,e.forEach=Ze,e.forEachSeries=He,e.forEachLimit=$e,e.forEachOf=Me,e.forEachOfSeries=je,e.forEachOfLimit=_e,e.inject=Ne,e.foldl=Ne,e.foldr=ae,e.select=at,e.selectLimit=it,e.selectSeries=rt,e.wrapSync=r,e.during=bt,e.doDuring=Je,Object.defineProperty(e,"__esModule",{value:!0})});
(function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.async={})})(this,function(e){'use strict';function t(e,...t){return(...a)=>e(...t,...a)}function a(e){return function(...t){var a=t.pop();return e.call(this,t,a)}}function n(e){setTimeout(e,0)}function i(e){return(t,...a)=>e(()=>t(...a))}function r(e){return u(e)?function(...t){const a=t.pop(),n=e.apply(this,t);return s(n,a)}:a(function(t,a){var n;try{n=e.apply(this,t)}catch(t){return a(t)}return n&&"function"==typeof n.then?s(n,a):void a(null,n)})}function s(e,t){return e.then(e=>{l(t,null,e)},e=>{l(t,e&&e.message?e:new Error(e))})}function l(e,t,a){try{e(t,a)}catch(e){Ee(t=>{throw t},e)}}function u(e){return"AsyncFunction"===e[Symbol.toStringTag]}function c(e){return"AsyncGenerator"===e[Symbol.toStringTag]}function d(e){return"function"==typeof e[Symbol.asyncIterator]}function p(e){if("function"!=typeof e)throw new Error("expected a function");return u(e)?r(e):e}function o(e,t=e.length){function a(...a){return"function"==typeof a[t-1]?e.apply(this,a):new Promise((n,i)=>{a[t-1]=(e,...t)=>e?i(e):void n(1<t.length?t:t[0]),e.apply(this,a)})}if(!t)throw new Error("arity is undefined");return Object.defineProperty(a,"name",{value:`awaitable(${e.name})`}),a}function h(e){return function(t,...a){const n=o(function(n){var i=this;return e(t,(e,t)=>{p(e).apply(i,a.concat(t))},n)});return n}}function f(e,t,a,n){t=t||[];var i=[],r=0,s=p(a);return e(t,(e,t,a)=>{var n=r++;s(e,(e,t)=>{i[n]=t,a(e)})},e=>{n(e,i)})}function y(e){return e&&"number"==typeof e.length&&0<=e.length&&0==e.length%1}function m(e){function t(...t){if(null!==e){var a=e;e=null,a.apply(this,t)}}return Object.assign(t,e),t}function g(e){return e[Symbol.iterator]&&e[Symbol.iterator]()}function k(e){var t=-1,a=e.length;return function(){return++t<a?{value:e[t],key:t}:null}}function v(e){var t=-1;return function(){var a=e.next();return a.done?null:(t++,{value:a.value,key:t})}}function S(e){var t=e?Object.keys(e):[],a=-1,n=t.length;return function(){var i=t[++a];return a<n?{value:e[i],key:i}:null}}function L(e){if(y(e))return k(e);var t=g(e);return t?v(t):S(e)}function x(e){return function(...t){if(null===e)throw new Error("Callback was already called.");var a=e;e=null,a.apply(this,t)}}function E(e,t,a,n){function i(){d>=t||c||l||(c=!0,e.next().then(({value:e,done:t})=>{if(!(u||l))return c=!1,t?(l=!0,void(0>=d&&n(null))):void(d++,a(e,p,r),p++,i())}).catch(s))}function r(e,t){return d-=1,u?void 0:e?s(e):!1===e?(l=!0,void(u=!0)):t===be||l&&0>=d?(l=!0,n(null)):void i()}function s(e){u||(c=!1,l=!0,n(e))}let l=!1,u=!1,c=!1,d=0,p=0;i()}function b(e,t,a){function n(e,t){!1===e&&(l=!0);!0===l||(e?a(e):(++r===s||t===be)&&a(null))}a=m(a);var i=0,r=0,{length:s}=e,l=!1;for(0===s&&a(null);i<s;i++)t(e[i],i,x(n))}function O(e,t,a){return _e(e,1/0,t,a)}function _(){function e(e,...n){return e?a(e):void t(1<n.length?n:n[0])}let t,a;return e[Fe]=new Promise((e,n)=>{t=e,a=n}),e}function M(e,t,a){function n(e,t){g.push(()=>l(e,t))}function i(){if(!h){if(0===g.length&&0===o)return a(null,d);for(;g.length&&o<t;){var e=g.shift();e()}}}function r(e,t){var a=y[e];a||(a=y[e]=[]),a.push(t)}function s(e){var t=y[e]||[];t.forEach(e=>e()),i()}function l(e,t){if(!f){var n=x((t,...n)=>{if(o--,!1===t)return void(h=!0);if(2>n.length&&([n]=n),t){var i={};if(Object.keys(d).forEach(e=>{i[e]=d[e]}),i[e]=n,f=!0,y=Object.create(null),h)return;a(t,i)}else d[e]=n,s(e)});o++;var i=p(t[t.length-1]);1<t.length?i(d,n):i(n)}}function u(t){var a=[];return Object.keys(e).forEach(n=>{const i=e[n];Array.isArray(i)&&0<=i.indexOf(t)&&a.push(n)}),a}"number"!=typeof t&&(a=t,t=null),a=m(a||_());var c=Object.keys(e).length;if(!c)return a(null);t||(t=c);var d={},o=0,h=!1,f=!1,y=Object.create(null),g=[],k=[],v={};return Object.keys(e).forEach(t=>{var a=e[t];if(!Array.isArray(a))return n(t,[a]),void k.push(t);var i=a.slice(0,a.length-1),s=i.length;return 0===s?(n(t,a),void k.push(t)):void(v[t]=s,i.forEach(l=>{if(!e[l])throw new Error("async.auto task `"+t+"` has a non-existent dependency `"+l+"` in "+i.join(", "));r(l,()=>{s--,0===s&&n(t,a)})}))}),function(){for(var e,t=0;k.length;)e=k.pop(),t++,u(e).forEach(e=>{0==--v[e]&&k.push(e)});if(t!==c)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}(),i(),a[Fe]}function A(e){const t=e.toString().replace(ze,"");let a=t.match(Pe);if(a||(a=t.match(Te)),!a)throw new Error("could not parse args in autoInject\nSource:\n"+t);let[,n]=a;return n.replace(/\s/g,"").split(Re).map(e=>e.replace(Ce,"").trim())}function I(e,t){var a={};return Object.keys(e).forEach(t=>{function n(e,t){var a=i.map(t=>e[t]);a.push(t),p(r)(...a)}var i,r=e[t],s=u(r),l=!s&&1===r.length||s&&0===r.length;if(Array.isArray(r))i=[...r],r=i.pop(),a[t]=i.concat(0<i.length?n:r);else if(l)a[t]=r;else{if(i=A(r),0===r.length&&!s&&0===i.length)throw new Error("autoInject task functions require explicit parameters.");s||i.pop(),a[t]=i.concat(n)}}),M(a,t)}function j(e,t){e.length=1,e.head=e.tail=t}function w(e,t,a){function n(e,t){f[e].push(t)}function i(e,t){const a=(...n)=>{r(e,a),t(...n)};f[e].push(a)}function r(e,t){return e?t?void(f[e]=f[e].filter(e=>e!==t)):f[e]=[]:Object.keys(f).forEach(e=>f[e]=[])}function s(e,...t){f[e].forEach(e=>e(...t))}function l(e,t,a,n){function i(e,...t){return e?a?s(e):r():1>=t.length?r(t[0]):void r(t)}if(null!=n&&"function"!=typeof n)throw new Error("task callback must be a function");k.started=!0;var r,s,l={data:e,callback:a?i:n||i};if(t?k._tasks.unshift(l):k._tasks.push(l),y||(y=!0,Ee(()=>{y=!1,k.process()})),a||!n)return new Promise((e,t)=>{r=e,s=t})}function u(e){return function(t,...a){o-=1;for(var n=0,r=e.length;n<r;n++){var l=e[n],u=h.indexOf(l);0===u?h.shift():0<u&&h.splice(u,1),l.callback(t,...a),null!=t&&s("error",t,l.data)}o<=k.concurrency-k.buffer&&s("unsaturated"),k.idle()&&s("drain"),k.process()}}function c(e){return!!(0===e.length&&k.idle())&&(Ee(()=>s("drain")),!0)}if(null==t)t=1;else if(0===t)throw new RangeError("Concurrency must not be zero");var d=p(e),o=0,h=[];const f={error:[],drain:[],saturated:[],unsaturated:[],empty:[]};var y=!1;const m=e=>t=>t?void(r(e),n(e,t)):new Promise((t,a)=>{i(e,(e,n)=>e?a(e):void t(n))});var g=!1,k={_tasks:new Ye,*[Symbol.iterator](){yield*k._tasks[Symbol.iterator]()},concurrency:t,payload:a,buffer:t/4,started:!1,paused:!1,push(e,t){return Array.isArray(e)?c(e)?void 0:e.map(e=>l(e,!1,!1,t)):l(e,!1,!1,t)},pushAsync(e,t){return Array.isArray(e)?c(e)?void 0:e.map(e=>l(e,!1,!0,t)):l(e,!1,!0,t)},kill(){r(),k._tasks.empty()},unshift(e,t){return Array.isArray(e)?c(e)?void 0:e.map(e=>l(e,!0,!1,t)):l(e,!0,!1,t)},unshiftAsync(e,t){return Array.isArray(e)?c(e)?void 0:e.map(e=>l(e,!0,!0,t)):l(e,!0,!0,t)},remove(e){k._tasks.remove(e)},process(){var e=Math.min;if(!g){for(g=!0;!k.paused&&o<k.concurrency&&k._tasks.length;){var t=[],a=[],n=k._tasks.length;k.payload&&(n=e(n,k.payload));for(var r,c=0;c<n;c++)r=k._tasks.shift(),t.push(r),h.push(r),a.push(r.data);o+=1,0===k._tasks.length&&s("empty"),o===k.concurrency&&s("saturated");var p=x(u(t));d(a,p)}g=!1}},length(){return k._tasks.length},running(){return o},workersList(){return h},idle(){return 0===k._tasks.length+o},pause(){k.paused=!0},resume(){!1===k.paused||(k.paused=!1,Ee(k.process))}};return Object.defineProperties(k,{saturated:{writable:!1,value:m("saturated")},unsaturated:{writable:!1,value:m("unsaturated")},empty:{writable:!1,value:m("empty")},drain:{writable:!1,value:m("drain")},error:{writable:!1,value:m("error")}}),k}function B(e,t){return w(e,1,t)}function F(e,t,a){return w(e,t,a)}function P(...e){var t=e.map(p);return function(...e){var a=this,n=e[e.length-1];return"function"==typeof n?e.pop():n=_(),Ne(t,e,(e,t,n)=>{t.apply(a,e.concat((e,...t)=>{n(e,t)}))},(e,t)=>n(e,...t)),n[Fe]}}function T(...e){return P(...e.reverse())}function R(...e){return function(...t){var a=t.pop();return a(null,...e)}}function C(e,t){return(a,n,i,r)=>{var s,l=!1;const u=p(i);a(n,(a,n,i)=>{u(a,(n,r)=>n||!1===n?i(n):e(r)&&!s?(l=!0,s=t(!0,a),i(null,be)):void i())},e=>e?r(e):void r(null,l?s:t(!1)))}}function z(e){return(t,...a)=>p(t)(...a,(t,...a)=>{"object"==typeof console&&(t?console.error&&console.error(t):console[e]&&a.forEach(t=>console[e](t)))})}function Y(e,t,a){const n=p(t);return Je(e,(...e)=>{const t=e.pop();n(...e,(e,a)=>t(e,!a))},a)}function V(e){return(t,a,n)=>e(t,n)}function N(e){return u(e)?e:function(...t){var a=t.pop(),n=!0;t.push((...e)=>{n?Ee(()=>a(...e)):a(...e)}),e.apply(this,t),n=!1}}function q(e,t,a,n){var r=Array(t.length);e(t,(e,t,n)=>{a(e,(e,a)=>{r[t]=!!a,n(e)})},e=>{if(e)return n(e);for(var a=[],s=0;s<t.length;s++)r[s]&&a.push(t[s]);n(null,a)})}function D(e,t,a,n){var i=[];e(t,(e,t,n)=>{a(e,(a,r)=>a?n(a):void(r&&i.push({index:t,value:e}),n(a)))},e=>e?n(e):void n(null,i.sort((e,t)=>e.index-t.index).map(e=>e.value)))}function Q(e,t,a,n){var i=y(t)?q:D;return i(e,t,p(a),n)}function U(e,t,a){return lt(e,1/0,t,a)}function G(e,t,a){return lt(e,1,t,a)}function W(e,t,a){return ct(e,1/0,t,a)}function K(e,t,a){return ct(e,1,t,a)}function X(e,t=e=>e){var n=Object.create(null),r=Object.create(null),s=p(e),l=a((e,a)=>{var u=t(...e);u in n?Ee(()=>a(null,...n[u])):u in r?r[u].push(a):(r[u]=[a],s(...e,(e,...t)=>{e||(n[u]=t);var a=r[u];delete r[u];for(var s=0,c=a.length;s<c;s++)a[s](e,...t)}))});return l.memo=n,l.unmemoized=e,l}function J(e,t){return pt(Me,e,t)}function Z(e,t,a){return pt(Oe(t),e,a)}function $(e,t){var a=p(e);return w((e,t)=>{a(e[0],t)},t,1)}function H(e){return(e<<1)+1}function ee(e){return(e+1>>1)-1}function te(e,t){return e.priority===t.priority?e.pushCount<t.pushCount:e.priority<t.priority}function ae(e,t){var a=$(e,t);return a._tasks=new ot,a.push=function(e,t=0,n=()=>{}){if("function"!=typeof n)throw new Error("task callback must be a function");if(a.started=!0,Array.isArray(e)||(e=[e]),0===e.length&&a.idle())return Ee(()=>a.drain());for(var r,s=0,u=e.length;s<u;s++)r={data:e[s],priority:t,callback:n},a._tasks.push(r);Ee(a.process)},delete a.unshift,a}function ne(e,t,a,n){var i=[...e].reverse();return Ne(i,t,a,n)}function ie(e){var t=p(e);return a(function(e,a){return e.push((e,...t)=>{let n={};if(e&&(n.error=e),0<t.length){var i=t;1>=t.length&&([i]=t),n.value=i}a(null,n)}),t.apply(this,e)})}function re(e){var t;return Array.isArray(e)?t=e.map(ie):(t={},Object.keys(e).forEach(a=>{t[a]=ie.call(this,e[a])})),t}function se(e,t,a,n){const i=p(a);return Q(e,t,(e,t)=>{i(e,(e,a)=>{t(e,!a)})},n)}function le(e){return function(){return e}}function ue(e,t,a){function n(){r((e,...t)=>{!1===e||(e&&s++<i.times&&("function"!=typeof i.errorFilter||i.errorFilter(e))?setTimeout(n,i.intervalFunc(s-1)):a(e,...t))})}var i={times:gt,intervalFunc:le(kt)};if(3>arguments.length&&"function"==typeof e?(a=t||_(),t=e):(ce(i,e),a=a||_()),"function"!=typeof t)throw new Error("Invalid arguments for async.retry");var r=p(t),s=1;return n(),a[Fe]}function ce(e,a){if("object"==typeof a)e.times=+a.times||gt,e.intervalFunc="function"==typeof a.interval?a.interval:le(+a.interval||kt),e.errorFilter=a.errorFilter;else if("number"==typeof a||"string"==typeof a)e.times=+a||gt;else throw new Error("Invalid arguments for async.retry")}function de(e,t){t||(t=e,e=null);let n=e&&e.arity||t.length;u(t)&&(n+=1);var i=p(t);return a((t,a)=>{function r(e){i(...t,e)}return(t.length<n-1||null==a)&&(t.push(a),a=_()),e?ue(e,r,a):ue(r,a),a[Fe]})}function pe(e,t){return pt(je,e,t)}function oe(e,t,n){var i=p(e);return a((a,r)=>{var s,l=!1;a.push((...e)=>{l||(r(...e),clearTimeout(s))}),s=setTimeout(function(){var t=e.name||"anonymous",a=new Error("Callback function \""+t+"\" timed out.");a.code="ETIMEDOUT",n&&(a.info=n),l=!0,r(a)},t),i(...a)})}function he(e){for(var t=Array(e);e--;)t[e]=e;return t}function fe(e,t,a,n){var i=p(a);return qe(he(e),t,i,n)}function ye(e,t,a){return fe(e,1/0,t,a)}function me(e,t,a){return fe(e,1,t,a)}function ge(e,t,a,n){3>=arguments.length&&"function"==typeof t&&(n=a,a=t,t=Array.isArray(e)?[]:{}),n=m(n||_());var i=p(a);return Me(e,(e,a,n)=>{i(t,e,a,n)},e=>n(e,t)),n[Fe]}function ke(e){return(...t)=>(e.unmemoized||e)(...t)}function ve(e,t,a){const n=p(e);return bt(e=>n((t,a)=>e(t,!a)),t,a)}var Se,Le="function"==typeof setImmediate&&setImmediate,xe="object"==typeof process&&"function"==typeof process.nextTick;Se=Le?setImmediate:xe?process.nextTick:n;var Ee=i(Se);const be={};var Oe=e=>(t,a,n)=>{function i(e,t){if(!u)if(p-=1,e)l=!0,n(e);else if(!1===e)l=!0,u=!0;else{if(t===be||l&&0>=p)return l=!0,n(null);o||r()}}function r(){for(o=!0;p<e&&!l;){var t=s();if(null===t)return l=!0,void(0>=p&&n(null));p+=1,a(t.value,t.key,x(i))}o=!1}if(n=m(n),0>=e)throw new RangeError("concurrency limit cannot be less than 1");if(!t)return n(null);if(c(t))return E(t,e,a,n);if(d(t))return E(t[Symbol.asyncIterator](),e,a,n);var s=L(t),l=!1,u=!1,p=0,o=!1;r()},_e=o(function(e,t,a,n){return Oe(t)(e,p(a),n)},4),Me=o(function(e,t,a){var n=y(e)?b:O;return n(e,p(t),a)},3),Ae=o(function(e,t,a){return f(Me,e,t,a)},3),Ie=h(Ae),je=o(function(e,t,a){return _e(e,1,t,a)},3),we=o(function(e,t,a){return f(je,e,t,a)},3),Be=h(we);const Fe=Symbol("promiseCallback");var Pe=/^(?:async\s+)?(?:function)?\s*\w*\s*\(\s*([^)]+)\s*\)(?:\s*{)/,Te=/^(?:async\s+)?\(?\s*([^)=]+)\s*\)?(?:\s*=>)/,Re=/,/,Ce=/(=.+)?(\s*)$/,ze=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;class Ye{constructor(){this.head=this.tail=null,this.length=0}removeLink(e){return e.prev?e.prev.next=e.next:this.head=e.next,e.next?e.next.prev=e.prev:this.tail=e.prev,e.prev=e.next=null,this.length-=1,e}empty(){for(;this.head;)this.shift();return this}insertAfter(e,t){t.prev=e,t.next=e.next,e.next?e.next.prev=t:this.tail=t,e.next=t,this.length+=1}insertBefore(e,t){t.prev=e.prev,t.next=e,e.prev?e.prev.next=t:this.head=t,e.prev=t,this.length+=1}unshift(e){this.head?this.insertBefore(this.head,e):j(this,e)}push(e){this.tail?this.insertAfter(this.tail,e):j(this,e)}shift(){return this.head&&this.removeLink(this.head)}pop(){return this.tail&&this.removeLink(this.tail)}toArray(){return[...this]}*[Symbol.iterator](){for(var e=this.head;e;)yield e.data,e=e.next}remove(e){for(var t=this.head;t;){var{next:a}=t;e(t)&&this.removeLink(t),t=a}return this}}var Ve,Ne=o(function(e,t,a,n){n=m(n);var r=p(a);return je(e,(e,a,n)=>{r(t,e,(e,a)=>{t=a,n(e)})},e=>n(e,t))},4),qe=o(function(e,t,a,n){return f(Oe(t),e,a,n)},4),De=o(function(e,t,a,n){var i=p(a);return qe(e,t,(e,t)=>{i(e,(e,...a)=>e?t(e):t(e,a))},(e,t)=>{for(var a=[],r=0;r<t.length;r++)t[r]&&(a=a.concat(...t[r]));return n(e,a)})},4),Qe=o(function(e,t,a){return De(e,1/0,t,a)},3),Ue=o(function(e,t,a){return De(e,1,t,a)},3),Ge=o(function(e,t,a){return C(e=>e,(e,t)=>t)(Me,e,t,a)},3),We=o(function(e,t,a,n){return C(e=>e,(e,t)=>t)(Oe(t),e,a,n)},4),Ke=o(function(e,t,a){return C(e=>e,(e,t)=>t)(Oe(1),e,t,a)},3),Xe=z("dir"),Je=o(function(e,t,a){function n(e,...t){return e?a(e):void(!1===e||(r=t,l(...t,i)))}function i(e,t){return e?a(e):!1===e?void 0:t?void s(n):a(null,...r)}a=x(a);var r,s=p(e),l=p(t);return i(null,!0)},3),Ze=o(function(e,t,a){return Me(e,V(p(t)),a)},3),$e=o(function(e,t,a,n){return Oe(t)(e,V(p(a)),n)},4),He=o(function(e,t,a){return $e(e,1,t,a)},3),et=o(function(e,t,a){return C(e=>!e,e=>!e)(Me,e,t,a)},3),tt=o(function(e,t,a,n){return C(e=>!e,e=>!e)(Oe(t),e,a,n)},4),at=o(function(e,t,a){return C(e=>!e,e=>!e)(je,e,t,a)},3),nt=o(function(e,t,a){return Q(Me,e,t,a)},3),it=o(function(e,t,a,n){return Q(Oe(t),e,a,n)},4),rt=o(function(e,t,a){return Q(je,e,t,a)},3),st=o(function(e,t){function a(e){return e?n(e):void(!1===e||i(a))}var n=x(t),i=p(N(e));return a()},2),lt=o(function(e,t,a,n){var i=p(a);return qe(e,t,(e,t)=>{i(e,(a,n)=>a?t(a):t(a,{key:n,val:e}))},(e,t)=>{for(var a={},{hasOwnProperty:r}=Object.prototype,s=0;s<t.length;s++)if(t[s]){var{key:l}=t[s],{val:u}=t[s];r.call(a,l)?a[l].push(u):a[l]=[u]}return n(e,a)})},4),ut=z("log"),ct=o(function(e,t,a,n){n=m(n);var i={},r=p(a);return Oe(t)(e,(e,t,a)=>{r(e,t,(e,n)=>e?a(e):void(i[t]=n,a(e)))},e=>n(e,i))},4);Ve=xe?process.nextTick:Le?setImmediate:n;var dt=i(Ve),pt=o((e,t,a)=>{var n=y(t)?[]:{};e(t,(e,t,a)=>{p(e)((e,...i)=>{2>i.length&&([i]=i),n[t]=i,a(e)})},e=>a(e,n))},3);class ot{constructor(){this.heap=[],this.pushCount=Number.MIN_SAFE_INTEGER}get length(){return this.heap.length}empty(){return this.heap=[],this}percUp(e){for(let a;0<e&&te(this.heap[e],this.heap[a=ee(e)]);){let n=this.heap[e];this.heap[e]=this.heap[a],this.heap[a]=n,e=a}}percDown(e){for(let a,n;(a=H(e))<this.heap.length&&(a+1<this.heap.length&&te(this.heap[a+1],this.heap[a])&&++a,!te(this.heap[e],this.heap[a]));)n=this.heap[e],this.heap[e]=this.heap[a],this.heap[a]=n,e=a}push(e){e.pushCount=++this.pushCount,this.heap.push(e),this.percUp(this.heap.length-1)}unshift(e){return this.heap.push(e)}shift(){let[e]=this.heap;return this.heap[0]=this.heap[this.heap.length-1],this.heap.pop(),this.percDown(0),e}toArray(){return[...this]}*[Symbol.iterator](){for(let e=0;e<this.heap.length;e++)yield this.heap[e].data}remove(e){let t=0;for(let a=0;a<this.heap.length;a++)e(this.heap[a])||(this.heap[t]=this.heap[a],t++);this.heap.splice(t);for(let t=ee(this.heap.length-1);0<=t;t--)this.percDown(t);return this}}var ht=o(function(e,t){if(t=m(t),!Array.isArray(e))return t(new TypeError("First argument to race must be an array of functions"));if(!e.length)return t();for(var a=0,n=e.length;a<n;a++)p(e[a])(t)},2),ft=o(function(e,t,a){return se(Me,e,t,a)},3),yt=o(function(e,t,a,n){return se(Oe(t),e,a,n)},4),mt=o(function(e,t,a){return se(je,e,t,a)},3);const gt=5,kt=0;var vt=o(function(e,t,a){return C(Boolean,e=>e)(Me,e,t,a)},3),St=o(function(e,t,a,n){return C(Boolean,e=>e)(Oe(t),e,a,n)},4),Lt=o(function(e,t,a){return C(Boolean,e=>e)(je,e,t,a)},3),xt=o(function(e,t,a){function n(e,t){var n=e.criteria,a=t.criteria;return n<a?-1:n>a?1:0}var i=p(t);return Ae(e,(e,t)=>{i(e,(a,n)=>a?t(a):void t(a,{value:e,criteria:n}))},(e,t)=>e?a(e):void a(null,t.sort(n).map(e=>e.value)))},3),Et=o(function(e,t){var a,n=null;return He(e,(e,t)=>{p(e)((e,...i)=>!1===e?t(e):void(2>i.length?[a]=i:a=i,n=e,t(e?null:{})))},()=>t(n,a))}),bt=o(function(e,t,a){function n(e,...t){if(e)return a(e);l=t;!1===e||s(i)}function i(e,t){return e?a(e):!1===e?void 0:t?void r(n):a(null,...l)}a=x(a);var r=p(t),s=p(e),l=[];return s(i)},3),Ot=o(function(e,t){function a(t){var a=p(e[i++]);a(...t,x(n))}function n(n,...r){return!1===n?void 0:n||i===e.length?t(n,...r):void a(r)}if(t=m(t),!Array.isArray(e))return t(new Error("First argument to waterfall must be an array of functions"));if(!e.length)return t();var i=0;a([])});e.default={apply:t,applyEach:Ie,applyEachSeries:Be,asyncify:r,auto:M,autoInject:I,cargo:B,cargoQueue:F,compose:T,concat:Qe,concatLimit:De,concatSeries:Ue,constant:R,detect:Ge,detectLimit:We,detectSeries:Ke,dir:Xe,doUntil:Y,doWhilst:Je,each:Ze,eachLimit:$e,eachOf:Me,eachOfLimit:_e,eachOfSeries:je,eachSeries:He,ensureAsync:N,every:et,everyLimit:tt,everySeries:at,filter:nt,filterLimit:it,filterSeries:rt,forever:st,groupBy:U,groupByLimit:lt,groupBySeries:G,log:ut,map:Ae,mapLimit:qe,mapSeries:we,mapValues:W,mapValuesLimit:ct,mapValuesSeries:K,memoize:X,nextTick:dt,parallel:J,parallelLimit:Z,priorityQueue:ae,queue:$,race:ht,reduce:Ne,reduceRight:ne,reflect:ie,reflectAll:re,reject:ft,rejectLimit:yt,rejectSeries:mt,retry:ue,retryable:de,seq:P,series:pe,setImmediate:Ee,some:vt,someLimit:St,someSeries:Lt,sortBy:xt,timeout:oe,times:ye,timesLimit:fe,timesSeries:me,transform:ge,tryEach:Et,unmemoize:ke,until:ve,waterfall:Ot,whilst:bt,all:et,allLimit:tt,allSeries:at,any:vt,anyLimit:St,anySeries:Lt,find:Ge,findLimit:We,findSeries:Ke,flatMap:Qe,flatMapLimit:De,flatMapSeries:Ue,forEach:Ze,forEachSeries:He,forEachLimit:$e,forEachOf:Me,forEachOfSeries:je,forEachOfLimit:_e,inject:Ne,foldl:Ne,foldr:ne,select:nt,selectLimit:it,selectSeries:rt,wrapSync:r,during:bt,doDuring:Je},e.apply=t,e.applyEach=Ie,e.applyEachSeries=Be,e.asyncify=r,e.auto=M,e.autoInject=I,e.cargo=B,e.cargoQueue=F,e.compose=T,e.concat=Qe,e.concatLimit=De,e.concatSeries=Ue,e.constant=R,e.detect=Ge,e.detectLimit=We,e.detectSeries=Ke,e.dir=Xe,e.doUntil=Y,e.doWhilst=Je,e.each=Ze,e.eachLimit=$e,e.eachOf=Me,e.eachOfLimit=_e,e.eachOfSeries=je,e.eachSeries=He,e.ensureAsync=N,e.every=et,e.everyLimit=tt,e.everySeries=at,e.filter=nt,e.filterLimit=it,e.filterSeries=rt,e.forever=st,e.groupBy=U,e.groupByLimit=lt,e.groupBySeries=G,e.log=ut,e.map=Ae,e.mapLimit=qe,e.mapSeries=we,e.mapValues=W,e.mapValuesLimit=ct,e.mapValuesSeries=K,e.memoize=X,e.nextTick=dt,e.parallel=J,e.parallelLimit=Z,e.priorityQueue=ae,e.queue=$,e.race=ht,e.reduce=Ne,e.reduceRight=ne,e.reflect=ie,e.reflectAll=re,e.reject=ft,e.rejectLimit=yt,e.rejectSeries=mt,e.retry=ue,e.retryable=de,e.seq=P,e.series=pe,e.setImmediate=Ee,e.some=vt,e.someLimit=St,e.someSeries=Lt,e.sortBy=xt,e.timeout=oe,e.times=ye,e.timesLimit=fe,e.timesSeries=me,e.transform=ge,e.tryEach=Et,e.unmemoize=ke,e.until=ve,e.waterfall=Ot,e.whilst=bt,e.all=et,e.allLimit=tt,e.allSeries=at,e.any=vt,e.anyLimit=St,e.anySeries=Lt,e.find=Ge,e.findLimit=We,e.findSeries=Ke,e.flatMap=Qe,e.flatMapLimit=De,e.flatMapSeries=Ue,e.forEach=Ze,e.forEachSeries=He,e.forEachLimit=$e,e.forEachOf=Me,e.forEachOfSeries=je,e.forEachOfLimit=_e,e.inject=Ne,e.foldl=Ne,e.foldr=ne,e.select=nt,e.selectLimit=it,e.selectSeries=rt,e.wrapSync=r,e.during=bt,e.doDuring=Je,Object.defineProperty(e,"__esModule",{value:!0})});

@@ -67,3 +67,3 @@ 'use strict';

var processingScheduled = false;
function _insert(data, insertAtFront, callback) {
function _insert(data, insertAtFront, rejectOnError, callback) {
if (callback != null && typeof callback !== 'function') {

@@ -73,17 +73,15 @@ throw new Error('task callback must be a function');

q.started = true;
/*if (Array.isArray(data)) {
return data.map(datum => _insert(datum, insertAtFront, callback));
}*/
var res;
var res, rej;
function promiseCallback(err, ...args) {
// we don't care about the error, let the global error handler
// deal with it
if (err) return rejectOnError ? rej(err) : res();
if (args.length <= 1) return res(args[0]);
res(args);
}
var item = {
data,
callback: callback || function (err, ...args) {
// we don't care about the error, let the global error handler
// deal with it
if (err) return;
if (args.length <= 1) return res(args[0]);
res(args);
}
callback: rejectOnError ? promiseCallback : callback || promiseCallback
};

@@ -105,5 +103,6 @@

if (!callback) {
return new Promise(resolve => {
if (rejectOnError || !callback) {
return new Promise((resolve, reject) => {
res = resolve;
rej = reject;
});

@@ -145,2 +144,11 @@ }

function _maybeDrain(data) {
if (data.length === 0 && q.idle()) {
// call drain immediately if there are no tasks
(0, _setImmediate2.default)(() => trigger('drain'));
return true;
}
return false;
}
const eventMethod = name => handler => {

@@ -172,10 +180,14 @@ if (!handler) {

if (Array.isArray(data)) {
if (data.length === 0 && q.idle()) {
// call drain immediately if there are no tasks
return (0, _setImmediate2.default)(() => trigger('drain'));
}
return data.map(datum => _insert(datum, false, callback));
if (_maybeDrain(data)) return;
return data.map(datum => _insert(datum, false, false, callback));
}
return _insert(data, false, callback);
return _insert(data, false, false, callback);
},
pushAsync(data, callback) {
if (Array.isArray(data)) {
if (_maybeDrain(data)) return;
return data.map(datum => _insert(datum, false, true, callback));
}
return _insert(data, false, true, callback);
},
kill() {

@@ -187,10 +199,14 @@ off();

if (Array.isArray(data)) {
if (data.length === 0 && q.idle()) {
// call drain immediately if there are no tasks
return (0, _setImmediate2.default)(() => trigger('drain'));
}
return data.map(datum => _insert(datum, true, callback));
if (_maybeDrain(data)) return;
return data.map(datum => _insert(datum, true, false, callback));
}
return _insert(data, true, callback);
return _insert(data, true, false, callback);
},
unshiftAsync(data, callback) {
if (Array.isArray(data)) {
if (_maybeDrain(data)) return;
return data.map(datum => _insert(datum, true, true, callback));
}
return _insert(data, true, true, callback);
},
remove(testFn) {

@@ -197,0 +213,0 @@ q._tasks.remove(testFn);

'use strict';
/* istanbul ignore file */

@@ -3,0 +4,0 @@ Object.defineProperty(exports, "__esModule", {

'use strict';
/* istanbul ignore file */

@@ -3,0 +4,0 @@ Object.defineProperty(exports, "__esModule", {

{
"name": "async",
"description": "Higher-order functions and common patterns for asynchronous code",
"version": "3.0.1",
"version": "3.1.0",
"main": "dist/async.js",

@@ -44,3 +44,2 @@ "author": "Caolan McMahon",

"fs-extra": "^0.26.7",
"gh-pages-deploy": "^0.5.1",
"jsdoc": "^3.4.0",

@@ -78,5 +77,2 @@ "karma": "^2.0.5",

"license": "MIT",
"gh-pages-deploy": {
"staticpath": "docs"
},
"nyc": {

@@ -87,3 +83,15 @@ "exclude": [

},
"module": "dist/async.mjs"
"module": "dist/async.mjs",
"browserify": {
"transform": [
[
"babelify",
{
"presets": [
"@babel/preset-env"
]
}
]
]
}
}

@@ -46,8 +46,12 @@ 'use strict';

* [cargo]{@link module:ControlFlow.cargo} object
* @property {Function} push - add a new task to the `queue`. Calls `callback`
* @property {AsyncFunction} push - add a new task to the `queue`. Calls `callback`
* once the `worker` has finished processing the task. Instead of a single task,
* a `tasks` array can be submitted. The respective callback is used for every
* task in the list. Invoke with `queue.push(task, [callback])`,
* @property {Function} unshift - add a new task to the front of the `queue`.
* @property {AsyncFunction} unshift - add a new task to the front of the `queue`.
* Invoke with `queue.unshift(task, [callback])`.
* @property {AsyncFunction} pushAsync - the same as `q.push`, except this returns
* a promise that rejects if an error occurs.
* @property {AsyncFunction} unshirtAsync - the same as `q.unshift`, except this returns
* a promise that rejects if an error occurs.
* @property {Function} remove - remove items from the queue that match a test

@@ -54,0 +58,0 @@ * function. The test function will be passed an object with a `data` property,

![Async Logo](https://raw.githubusercontent.com/caolan/async/master/logo/async-logo_readme.jpg)
[![Build Status via Travis CI](https://travis-ci.org/caolan/async.svg?branch=master)](https://travis-ci.org/caolan/async)
[![Build Status via Azure Pipelines](https://dev.azure.com/caolanmcmahon/async/_apis/build/status/caolan.async?branchName=master)](https://dev.azure.com/caolanmcmahon/async/_build/latest?definitionId=1&branchName=master)
[![NPM version](https://img.shields.io/npm/v/async.svg)](https://www.npmjs.com/package/async)
[![Coverage Status](https://coveralls.io/repos/caolan/async/badge.svg?branch=master)](https://coveralls.io/r/caolan/async?branch=master)
[![Join the chat at https://gitter.im/caolan/async](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/caolan/async?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![libhive - Open source examples](https://www.libhive.com/providers/npm/packages/async/examples/badge.svg)](https://www.libhive.com/providers/npm/packages/async)
[![jsDelivr Hits](https://data.jsdelivr.com/v1/package/npm/async/badge?style=rounded)](https://www.jsdelivr.com/package/npm/async)
<!--
|Linux|Windows|MacOS|
|-|-|-|
|[![Linux Build Status](https://dev.azure.com/caolanmcmahon/async/_apis/build/status/caolan.async?branchName=master&jobName=Linux&configuration=Linux%20node_10_x)](https://dev.azure.com/caolanmcmahon/async/_build/latest?definitionId=1&branchName=master) | [![Windows Build Status](https://dev.azure.com/caolanmcmahon/async/_apis/build/status/caolan.async?branchName=master&jobName=Windows&configuration=Windows%20node_10_x)](https://dev.azure.com/caolanmcmahon/async/_build/latest?definitionId=1&branchName=master) | [![MacOS Build Status](https://dev.azure.com/caolanmcmahon/async/_apis/build/status/caolan.async?branchName=master&jobName=OSX&configuration=OSX%20node_10_x)](https://dev.azure.com/caolanmcmahon/async/_build/latest?definitionId=1&branchName=master)| -->

@@ -11,0 +15,0 @@ Async is a utility module which provides straight-forward, powerful functions for working with [asynchronous JavaScript](http://caolan.github.io/async/global.html). Although originally designed for use with [Node.js](https://nodejs.org/) and installable via `npm install async`, it can also be used directly in the browser. A ESM version is included in the main `async` package that should automatically be used with compatible bundlers such as Webpack and Rollup.

@@ -43,3 +43,5 @@ 'use strict';

* const results = []
* async.until(function iter(next) {
* async.until(function test(page, cb) {
* cb(null, page.next == null)
* }, function iter(next) {
* fetchPage(url, (err, body) => {

@@ -50,4 +52,2 @@ * if (err) return next(err)

* })
* }, function test(page, cb) {
* cb(null, page.next == null)
* }, function done (err) {

@@ -54,0 +54,0 @@ * // all pages have been fetched

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc