/**
 * Shared async utilities for the CLI.
 */
import { promises as fs } from 'fs';
export async function pathExists(path) {
    try {
        await fs.access(path);
        return true;
    }
    catch {
        return false;
    }
}
export async function runWithLimit(items, limit, worker) {
    let index = 0;
    const workers = Array.from({ length: Math.min(limit, items.length) }, async () => {
        while (true) {
            const current = index++;
            if (current >= items.length)
                break;
            await worker(items[current]);
        }
    });
    await Promise.all(workers);
}
//# sourceMappingURL=async-utils.js.map