import { logVerbose, shouldLogVerbose } from "../globals.js"; import { runTasksWithConcurrency } from "../utils/run-with-concurrency.js"; export async function runWithConcurrency( tasks: Array<() => Promise>, limit: number, ): Promise { const { results } = await runTasksWithConcurrency({ tasks, limit, onTaskError(err) { if (shouldLogVerbose()) { logVerbose(`Media understanding task failed: ${String(err)}`); } }, }); return results; }