UNPKG

fishbird

Version:

Fishbird is a simple, lightweight, and fast Promise utility library

5 lines 615 B
'use strict'; function h(e,p,{concurrency:t=1/0}={concurrency:1/0}){if(typeof t!="number")throw new TypeError(`${String(t)} is not a number`);if(!Array.isArray(e))throw new TypeError(`arr must be collection, but got ${typeof e}`);let c=p||(n=>n);return new Promise((n,y)=>{let l=0,r=0,i=0,u=new Array(e.length).fill(void 0),f=!1;function w(o){let a=e[o];Promise.resolve(c.call(a,a,o,e)).then(s=>{i--,l++,u[o]=s,m();}).catch(s=>{f=!0,y(s);});}function m(){if(!f){if(l>=e.length){n(u);return}for(;i<t&&r<e.length;)w(r),i++,r++;}}m();})}var d=h; exports.a = h; exports.b = d; //# sourceMappingURL=chunk-XKPNVXGG.js.map