@node-libraries/promise-limit
Version:
Limits the maximum number of asynchronous processes that can be executed
10 lines • 434 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.promiseLimit = void 0;
const promiseLimit = (ps = new Set()) => ({
add: (p) => ps.add(typeof p === 'function' ? p() : !!p.then(() => ps.delete(p)).catch(() => ps.delete(p)) && p),
wait: (limit) => ps.size >= limit && Promise.race(ps),
all: () => Promise.all(ps),
});
exports.promiseLimit = promiseLimit;
//# sourceMappingURL=index.js.map