login/node_modules/asyncc/dist/index.min.js
2024-01-17 15:17:40 +08:00

1 line
5.6 KiB
JavaScript

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t="object"==typeof process&&"function"==typeof process.nextTick?process.nextTick:"function"==typeof setImmediate?setImmediate:function(t){setTimeout(t,0)},n=function(t){function n(n,e,i){t.call(this,n),Object.assign(this,{name:"AsynccError",message:n,errors:e,errpos:i,stack:this.stack||(new t).stack})}return t&&(n.__proto__=t),n.prototype=Object.create(t&&t.prototype),n.prototype.constructor=n,n}(Error);function e(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];return 1===t.length&&Array.isArray(t[0])&&(t=t[0]),function(n,e){var i=0;!function n(r,s){var o=t[i++];r||!o?e&&e(r,s):o(s,n)}(null,n)}}function i(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];return 1===t.length&&Array.isArray(t[0])&&(t=t[0]),function(n,e){var i=0;!function n(r,s){var o=t[i++];try{if(r){for(;o&&3!==o.length;)o=t[i++];o&&o(r,s,n)}else{for(;o&&o.length>2;)o=t[i++];o&&o(s,n)}}catch(t){n(t,s)}o||e&&e(r,s)}(null,n)}}function r(n,e,i){var r=0;function s(n,s){n||e(r)?i&&i(n,s):t((function(){o()}))}function o(){n(s,r++)}o()}function s(t,n,e){r(t,(function(t){return!n(t)}),e)}function o(t,e,i,r,s){void 0===r&&(r={}),"function"==typeof r&&(s=r,r={}),t=Math.abs(t||e);var o=[],u=new Array(e).fill(),c=new Array(e).fill(),h=0,f=e,a=0;if(0!==f)for(r.timeout&&setTimeout((function(){f&&l("err_timeout")}),r.timeout),t=t<e?t:e;h<t;)i(h++,p);else l();function l(t){if(!a++){var e=null;(o.length||t)&&(e=new n(t||"err",u,o)),s&&s(e,c)}}function p(t,n,s){c[t]=s,u[t]=n,n&&(o.push(t),r.bail)?l("err_bail"):(f--,h<e?i(h++,p):f||l())}}function u(t,n,e,i,r){o(t,n.length,(function(t,i){e(n[t],(function(n,e){i(t,n,e)}),t)}),i,r)}function c(t,n,e,i){u(0,t,n,e,i)}function h(n,e,i){var r=n.length,s=[],o=0;function u(n,e){s.push(e),n||r===o?i&&i(n,s):o<r&&t((function(){c()}))}function c(){e(n[o],u,o++)}0!==r?c():i(null,[])}function f(t){this._tasks=[],this.result=t,this.error=void 0,this._lock=!1}function a(t){return new f(t)}function l(t,n,e,i){o(t,n.length,(function(t,e){n[t]((function(n,i){e(t,n,i)}))}),e,i)}function p(t,n,e){l(0,t,n,e)}function _(){this.reset()}function m(t,n){this._task=t,this._concurrency=Math.abs(n||1),this._worker=0,this._paused=!1,this._items=new _}function y(t,n){return new m(t,n)}function d(n,e){e=e||{};var i=t,r=0,s=n;return"number"!=typeof n&&(s=n.times,r=n.lag||0),s=s||e.times||0,r&&(i=setTimeout),{times:s,lag:r,fn:i}}function g(t,n,e){var i=0,r=d(t,{times:2}),s=r.times,o=r.lag,u=r.fn;function c(t,n){!t||i>=s?e&&e(t,n):u((function(){h()}),o)}function h(){n(c,i++)}h()}function v(n,e){var i=n.length,r=[],s=0;function o(){n[s++](u)}function u(n,u){r.push(u),n||i===s?e&&e(n,r):s<i&&t((function(){o()}))}0!==i?o():e(null,[])}function k(t,n,e){var i=0,r=d(t),s=r.times,o=r.lag,u=r.fn;function c(t,n){t||s>0&&i>=s?e&&e(t,n):u((function(){h()}),o)}function h(){n(c,i++)}s?h():e&&e()}function x(n,e,i){var r=0;function s(e,s){e||n(r)?i&&i(e,s):t((function(){o()}))}function o(){e(s,r++)}n(r)?i&&i():o()}function w(t,n,e){x((function(n){return!t(n)}),n,e)}f.prototype={_run:function(){var t=this;if(!this._lock){this._lock=!0;for(var n=this._tasks.shift(),e=this.error?["catch","end"]:["then","end"];n&&!~e.indexOf(n.type);)n=this._tasks.shift();if(n){var i=function(n,e){t.error=n,t.result=e||t.result,t._lock=!1,t._run()},r=n.fn;if("end"===n.type)r(this.error,this.result);else try{"catch"===n.type?r(this.error,this.result,i):r(this.result,i)}catch(t){i(t)}}else this._lock=!1}},then:function(t){return this._tasks.push({type:"then",fn:t}),this._run(),this},catch:function(t){return this._tasks.push({type:"catch",fn:t}),this._run(),this},end:function(t){this._tasks.push({type:"end",fn:t}),this._run()}},_.prototype={get length(){return this.items.length},shift:function(){return(this.items.shift()||{}).item},push:function(t,n){var e=this.items;if("number"!=typeof n)n=1/0,e.push({prio:n,item:t});else{var i;n=Math.abs(n);for(var r=0;r<e.length;r++)if(n<e[r].prio){e.splice(r,0,{prio:n,item:t}),i=!0;break}i||e.push({prio:n,item:t})}return this},unshift:function(t){return this.items.unshift({prio:0,item:t}),this},reset:function(){this.items=[]}},m.prototype={_run:function(){var n=this,e=this._items,i=this._drain;if(this._worker-=1,0===e.length)this._worker<=0&&(this._worker=0,i&&i());else{this._worker+=1;var r=e.shift(),s=r[0],o=r[1];this._task(s,(function(e,i){o&&o(e,i),t((function(){n._run()}))}))}},_start:function(){for(;!this._paused&&this._worker<Math.min(this._concurrency,this._items.length);)this._worker+=1,this._run();return this},get paused(){return this._paused},get idle(){return!this.length&&0===this._worker},get length(){return this._items.length},pause:function(){return this._paused=!0,this},resume:function(){return this._paused=!1,this._start()},reset:function(){return this._items.reset(),this},running:function(){return this._worker},push:function(t,n,e){return this.concat([t],n,e)},concat:function(t,n,e){var i=this;return"number"==typeof n&&(e=n,n=void 0),t.forEach((function(t){i._items.push([t,n],e)})),this._start()},unshift:function(t,n){return this._items.unshift([t,n]),this._start()},drain:function(t){return this._drain=t,this}};var b={_setImmediate:t,AsynccError:n,compose:e,connect:i,doUntil:r,doWhilst:s,each:c,eachLimit:u,eachSeries:h,noPromise:a,NoPromise:f,parallel:p,parallelLimit:l,queue:y,Queue:m,retry:g,series:v,times:k,until:x,whilst:w};exports.AsynccError=n,exports.NoPromise=f,exports.Queue=m,exports._setImmediate=t,exports.compose=e,exports.connect=i,exports.default=b,exports.doUntil=r,exports.doWhilst=s,exports.each=c,exports.eachLimit=u,exports.eachSeries=h,exports.noPromise=a,exports.parallel=p,exports.parallelLimit=l,exports.queue=y,exports.retry=g,exports.series=v,exports.times=k,exports.until=x,exports.whilst=w;