one
Version:
One is a new React Framework that makes Vite serve both native and web.
25 lines (24 loc) • 504 B
JavaScript
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