UNPKG

one

Version:

One is a React framework for web, iOS, and Android apps.

26 lines (24 loc) • 457 B
function pLimit(concurrency) { const queue = []; let active = 0; const next = () => { if (active < concurrency && queue.length > 0) { active++; const fn = queue.shift(); fn(); } }; return (fn) => { return new Promise((resolve, reject) => { queue.push(() => { fn().then(resolve).catch(reject).finally(() => { active--; next(); }); }); next(); }); }; } export { pLimit }; //# sourceMappingURL=pLimit.mjs.map