UNPKG

fishbird

Version:

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

3 lines 609 B
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}`);const c=p||(n=>n);return new Promise((n,y)=>{let l=0,r=0,i=0;const u=new Array(e.length).fill(void 0);let f=!1;function w(o){const 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 I=h; export { I as default, h as map }; //# sourceMappingURL=map.js.map