michangarrito/apps/mcp-server/node_modules/hono/dist/utils/concurrent.js
rckrdmrd 48dea7a5d0 feat: Initial commit - michangarrito
Marketplace móvil para negocios locales mexicanos.

Estructura inicial:
- apps/backend (NestJS API)
- apps/frontend (React Web)
- apps/mobile (Expo/React Native)
- apps/mcp-server (Claude MCP Server)
- apps/whatsapp-service (WhatsApp Business API)
- database/ (PostgreSQL DDL)
- docs/ (Documentación)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-07 04:41:02 -06:00

40 lines
853 B
JavaScript

// src/utils/concurrent.ts
var DEFAULT_CONCURRENCY = 1024;
var createPool = ({
concurrency,
interval
} = {}) => {
concurrency ||= DEFAULT_CONCURRENCY;
if (concurrency === Infinity) {
return {
run: async (fn) => fn()
};
}
const pool = /* @__PURE__ */ new Set();
const run = async (fn, promise, resolve) => {
if (pool.size >= concurrency) {
promise ||= new Promise((r) => resolve = r);
setTimeout(() => run(fn, promise, resolve));
return promise;
}
const marker = {};
pool.add(marker);
const result = await fn();
if (interval) {
setTimeout(() => pool.delete(marker), interval);
} else {
pool.delete(marker);
}
if (resolve) {
resolve(result);
return promise;
} else {
return result;
}
};
return { run };
};
export {
createPool
};