You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
21 KiB
JavaScript

5 years ago
(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