asyncro
Version:
Asynchronous Array Utilities (for await)
3 lines (2 loc) • 1.34 kB
JavaScript
function n(n,r){return Promise.all(n.map(r))}function r(n){var r=Array.isArray(n)?[]:{};for(var t in n)n.hasOwnProperty(t)&&(r[t]=n[t]());return r}function t(n,r){return new Promise(function(t,e){return r().then(function(r){try{return n.push(r),t(n)}catch(n){return e(n)}}.bind(this),e)}.bind(this))}function e(r){var t=this;return function(e,i){return new Promise(function(t,u){var o;return n(e,i).then(function(n){try{return o=n,t(e[r](function(n,r){return o[r]}))}catch(n){return u(n)}}.bind(this),u)}.bind(t))}}function i(n,r,t){return new Promise(function(e,i){var u,o=0;return(u=function(n){for(;n;){if(n.then)return void n.then(u,i);try{if(n.pop){if(n.length)return n.pop()?f.call(this):n;n=c}else n=n.call(this)}catch(n){return i(n)}}}.bind(this))(s);function s(){return o<n.length?r(t,n[o],o,n).then(function(n){try{return t=n,c}catch(n){return i(n)}}.bind(this),i):[1]}function c(){return o++,s}function f(){return e(t)}}.bind(this))}var u=e("filter"),o=e("find"),s=e("every"),c=e("some");function f(n){return new Promise(function(t,e){return Promise.all(r(n)).then(t,e)}.bind(this))}function h(n){return new Promise(function(r,e){return r(i(n,t,[]))}.bind(this))}exports.reduce=i,exports.map=n,exports.filter=u,exports.find=o,exports.every=s,exports.some=c,exports.parallel=f,exports.series=h;
//# sourceMappingURL=asyncro.js.map